Skip to content

Commit 2df3ac2

Browse files
authored
fix(material-experimental/mdc-select): fix long labels being incorrectly cut off (#21184)
1 parent ab19ecc commit 2df3ac2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/material-experimental/mdc-select/select.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ $mat-select-arrow-size: 5px !default;
88
$mat-select-arrow-margin: 4px !default;
99
$mat-select-panel-max-height: 256px !default;
1010
$mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-arrow-margin);
11+
$leading-width: 12px !default;
12+
$scale: 0.75 !default;
1113

1214
// We base the select panel styling on top of MDC's menu styles and we
1315
// implement the trigger ourselves since MDC doesn't provide an equivalent.
@@ -116,3 +118,27 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
116118
display: block;
117119
}
118120
}
121+
122+
// Our MDC form field implementation is based on the MDC text field which doesn't include styles
123+
// for select. The select specific styles are not present as they don't use their text field as a
124+
// container. Below are the styles to account for the select arrow icon at the end.
125+
.mat-mdc-form-field-type-mat-select {
126+
&.mat-form-field-appearance-fill {
127+
.mdc-floating-label {
128+
max-width: calc(100% - #{$mat-select-placeholder-arrow-space});
129+
}
130+
131+
.mdc-floating-label--float-above {
132+
max-width: calc(100% / #{$scale} - #{$mat-select-placeholder-arrow-space / $scale});
133+
}
134+
}
135+
&.mat-form-field-appearance-outline {
136+
.mdc-notched-outline__notch {
137+
max-width: calc(100% - #{2 * ($mat-select-placeholder-arrow-space + $leading-width)});
138+
}
139+
140+
.mdc-text-field--label-floating .mdc-notched-outline__notch {
141+
max-width: calc(100% - #{$leading-width * 2});
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)