Skip to content

Commit 474d3f7

Browse files
committed
fix(material/form-field): label not truncated in fill appearance
Fixes that the label text wasn't being truncated for form fields with the `fill` appearance, because MDC only sets a `max-width` on outlined form field labels. Fixes #26337.
1 parent 66a93b9 commit 474d3f7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/material/form-field/_mdc-text-field-structure-overrides.scss

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
border: none;
2121
}
2222

23+
// TODO(crisbeto): port this fix over into MDC
24+
// MDC only sets a max-width form outlined form fields, but we need it
25+
// for filled ones as well in order for the text truncation to work.
26+
.mat-form-field-appearance-fill {
27+
.mdc-floating-label {
28+
max-width: 100%;
29+
}
30+
31+
.mdc-floating-label--float-above {
32+
max-width: 133.33%;
33+
}
34+
}
35+
2336
.mat-mdc-form-field .mat-mdc-floating-label.mdc-floating-label {
2437
// In order to ensure proper alignment of the floating label, we reset its line-height.
2538
// The line-height is not important as the element is absolutely positioned and only has one
@@ -135,5 +148,4 @@
135148
.mat-mdc-text-field-wrapper::before {
136149
content: none;
137150
}
138-
139151
}

0 commit comments

Comments
 (0)