简体   繁体   中英

Mat Chip List opon selection expands input

Giving the default behavior, when value is selected from a dropdown, MatChip appears within the input, but also expands it. I am a bit surprised this is the default behavior. Anyone can suggest how they fix it? Providing a forked StackBlitz demo (source take from Angular Material documentation):

DEMO

You can see in the images bellow - when chip selected, input becomes taller.

在此处输入图像描述 在此处输入图像描述

Problem

The problem is mat-form-field-infix class. When there are chips in the input, they increase the height.

Solution

You can set the minimal height for that class to be the same as when there are chips in the input. You can do it in the CSS file like this:

::ng-deep .mat-form-field-infix {
  min-height: 32px;
}

Working example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM