File tree Expand file tree Collapse file tree 4 files changed +18
-27
lines changed Expand file tree Collapse file tree 4 files changed +18
-27
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,13 @@ export class MatFormFieldNotchedOutline implements AfterViewInit {
60
60
}
61
61
62
62
_getNotchWidth ( ) {
63
- if ( this . open ) {
64
- const NOTCH_ELEMENT_PADDING = 8 ;
65
- const NOTCH_ELEMENT_BORDER = 1 ;
66
- return this . labelWidth > 0
67
- ? `calc(${ this . labelWidth } px * var(--mat-mdc-form-field-floating-label-scale, 0.75) + ${
68
- NOTCH_ELEMENT_PADDING + NOTCH_ELEMENT_BORDER
69
- } px)`
70
- : '0px' ;
63
+ if ( ! this . open || ! this . labelWidth ) {
64
+ return null ;
71
65
}
72
-
73
- return null ;
66
+ const NOTCH_ELEMENT_PADDING = 8 ;
67
+ const NOTCH_ELEMENT_BORDER = 1 ;
68
+ return `calc(${ this . labelWidth } px * var(--mat-mdc-form-field-floating-label-scale, 0.75) + ${
69
+ NOTCH_ELEMENT_PADDING + NOTCH_ELEMENT_BORDER
70
+ } px)`;
74
71
}
75
72
}
Original file line number Diff line number Diff line change 17
17
< label matFormFieldFloatingLabel
18
18
[floating] ="_shouldLabelFloat() "
19
19
*ngIf ="_hasFloatingLabel() "
20
- (cdkObserveContent) ="_refreshOutlineNotchWidth() "
21
- [cdkObserveContentDisabled] ="!_hasOutline() "
22
20
[id] ="_labelId "
23
21
[attr.for] ="_control.id "
24
- [attr.aria-owns] ="_control.id ">
22
+ [attr.aria-owns] ="_control.id "
23
+ (resized) ="_refreshOutlineNotchWidth() ">
25
24
< ng-content select ="mat-label "> </ ng-content >
26
25
<!--
27
26
We set the required marker as a separate element, in order to make it easier to target if
Original file line number Diff line number Diff line change 148
148
@include mdc-line-ripple .core-styles ($query : animation );
149
149
}
150
150
}
151
+
152
+ // Allow the label to grow 1px bigger than the notch.
153
+ // If we see this actually happen we know we need to resize the notch.
154
+ .mdc-notched-outline .mdc-floating-label {
155
+ max-width : calc (100% + 1px );
156
+ }
157
+ .mdc-notched-outline--upgraded .mdc-floating-label--float-above {
158
+ max-width : calc (100% * 4 / 3 + 1px );
159
+ }
Original file line number Diff line number Diff line change @@ -313,20 +313,6 @@ export class MatFormField
313
313
// Initial notch width update. This is needed in case the text-field label floats
314
314
// on initialization, and renders inside of the notched outline.
315
315
this . _refreshOutlineNotchWidth ( ) ;
316
- // Make sure fonts are loaded before calculating the width.
317
- // zone.js currently doesn't patch the FontFaceSet API so two calls to
318
- // _refreshOutlineNotchWidth is needed for this to work properly in async tests.
319
- // Furthermore if the font takes a long time to load we want the outline notch to be close
320
- // to the correct width from the start then correct itself when the fonts load.
321
- if ( this . _document ?. fonts ?. ready ) {
322
- this . _document . fonts . ready . then ( ( ) => {
323
- this . _refreshOutlineNotchWidth ( ) ;
324
- this . _changeDetectorRef . markForCheck ( ) ;
325
- } ) ;
326
- } else {
327
- // FontFaceSet is not supported in IE
328
- setTimeout ( ( ) => this . _refreshOutlineNotchWidth ( ) , 100 ) ;
329
- }
330
316
// Enable animations now. This ensures we don't animate on initial render.
331
317
this . _subscriptAnimationState = 'enter' ;
332
318
// Because the above changes a value used in the template after it was checked, we need
You can’t perform that action at this time.
0 commit comments