Skip to content

Commit

Permalink
fix(material-experimental/mdc-form-field): avoid expression ch… (#18741)
Browse files Browse the repository at this point in the history
There is currently a bug in the Angular Framework that results in
ExpressionChangedAfterItHasBeenChecked errors not throwing when they
should for OnPush components. Becuase we modify a variable used in the
template after it was already checked (in ngAfterViewInit), we need to
trigger change detection manually or the change might not be picked up.
  • Loading branch information
atscott authored and mmalerba committed Mar 6, 2020
1 parent e0c4d9e commit 65a602f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/material-experimental/mdc-form-field/form-field.ts
Expand Up @@ -330,6 +330,9 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck
this._refreshOutlineNotchWidth();
// Enable animations now. This ensures we don't animate on initial render.
this._subscriptAnimationState = 'enter';
// Because the above changes a value used in the template after it was checked, we need
// to trigger CD or the change might not be reflected if there is no other CD scheduled.
this._changeDetectorRef.detectChanges();
}

ngAfterContentInit() {
Expand Down

0 comments on commit 65a602f

Please sign in to comment.