Skip to content

Commit 55721bc

Browse files
committed
fix(material-experimental/mdc-form-field): make sure fonts are loaded before calculating notch width
1 parent e436479 commit 55721bc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/material-experimental/mdc-form-field/form-field.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,15 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck
340340
this._updateFocusState();
341341
// Initial notch width update. This is needed in case the text-field label floats
342342
// on initialization, and renders inside of the notched outline.
343-
this._refreshOutlineNotchWidth();
343+
if (this._platform.TRIDENT) {
344+
// FontFaceSet API is not supported in IE
345+
setTimeout(() => this._refreshOutlineNotchWidth());
346+
} else {
347+
// Make sure fonts are loaded before calculating the width.
348+
// FontFaceSet is technically still an experimental API at this time so the cast is needed
349+
// as experimental API's aren't in the lib file.
350+
(document as any).fonts.ready.then(() => this._refreshOutlineNotchWidth());
351+
}
344352
// Enable animations now. This ensures we don't animate on initial render.
345353
this._subscriptAnimationState = 'enter';
346354
// Because the above changes a value used in the template after it was checked, we need

0 commit comments

Comments
 (0)