From a5592f880c29ea86fd0791cdc52b6b5141a4c005 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 13 May 2025 10:13:51 +0200 Subject: [PATCH] fix(material/form-field): floating label triggering callback inside zone The floating label has a `setTimeout` inside `_handleResize` which was being called inside the zone from the `floating` setter which can trigger unnecessary change detections. --- src/material/form-field/directives/floating-label.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material/form-field/directives/floating-label.ts b/src/material/form-field/directives/floating-label.ts index 0af52fbb7058..69cbaeaffa50 100644 --- a/src/material/form-field/directives/floating-label.ts +++ b/src/material/form-field/directives/floating-label.ts @@ -116,7 +116,7 @@ export class MatFormFieldFloatingLabel implements OnDestroy { // This is expected, but If we allow this to all happen within the same macro task it causes an // error: `ResizeObserver loop limit exceeded`. Therefore we push the notch resize out until // the next macro task. - setTimeout(() => this._parent._handleLabelResized()); + this._ngZone.runOutsideAngular(() => setTimeout(() => this._parent._handleLabelResized())); } /** Subscribes to resize events. */