Skip to content

Commit

Permalink
fix(material-experimental/mdc-progress-bar): run resize observer outs…
Browse files Browse the repository at this point in the history
…ide zone

Runs the `ResizeObserver` from the progress bar outside of the `NgZone` so that it doesn't
trigger change detection.
  • Loading branch information
crisbeto committed Jan 21, 2021
1 parent acb3f33 commit d028768
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/material-experimental/mdc-progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
(window as unknown as WithMDCResizeObserver).ResizeObserver;

if (resizeObserverConstructor) {
const observer = new resizeObserverConstructor(callback);
observer.observe(this._rootElement);
return observer;
return this._ngZone.runOutsideAngular(() => {
const observer = new resizeObserverConstructor(callback);
observer.observe(this._rootElement);
return observer;
});
}

return null;
Expand Down

0 comments on commit d028768

Please sign in to comment.