Skip to content

fix(form-field): infinite loop with zone-patch-rxjs #15335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/lib/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,18 @@ export class MatFormField extends _MatFormFieldMixinBase

// @breaking-change 7.0.0 Remove this check once _ngZone is required. Also reconsider
// whether the `ngAfterContentChecked` below is still necessary.
if (this._ngZone) {
this._ngZone.onStable.asObservable().pipe(takeUntil(this._destroyed)).subscribe(() => {
if (this._outlineGapCalculationNeededOnStable) {
this.updateOutlineGap();
}
const zone = this._ngZone;

if (zone) {
// Note that we have to run outside of the `NgZone` explicitly,
// in order to avoid throwing users into an infinite loop
// if `zone-patch-rxjs` is included.
zone.runOutsideAngular(() => {
zone.onStable.asObservable().pipe(takeUntil(this._destroyed)).subscribe(() => {
if (this._outlineGapCalculationNeededOnStable) {
this.updateOutlineGap();
}
});
});
}

Expand Down