Skip to content

Commit d011c7c

Browse files
committed
fix(material-experimental/mdc-progress-bar): run resize observer outside zone
Runs the `ResizeObserver` from the progress bar outside of the `NgZone` so that it doesn't trigger change detection.
1 parent f5bb3b0 commit d011c7c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/material-experimental/mdc-progress-bar/progress-bar.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
9292
(this._rootElement.style as any)[styleProperty] = value;
9393
},
9494
getWidth: () => this._rootElement.offsetWidth,
95-
attachResizeObserver: (callback) => {
96-
if ((typeof window !== 'undefined') && window.ResizeObserver) {
97-
const ro = new ResizeObserver(callback);
98-
ro.observe(this._rootElement);
99-
return ro;
95+
attachResizeObserver: callback => {
96+
if (typeof window !== 'undefined' && window.ResizeObserver) {
97+
return this._ngZone.runOutsideAngular(() => {
98+
const resizeObserver = new ResizeObserver(callback);
99+
resizeObserver.observe(this._rootElement);
100+
return resizeObserver;
101+
});
100102
}
101103

102104
return null;

0 commit comments

Comments
 (0)