fix(mdc chips) Fix matChipRemove Expression has changed errors (#16574)

This line works fine with mat-icon, but was causing errors in a
unit test environment when matChipRemove was on a button element.

Defer the tab index update to avoid the errors.
This commit is contained in:
Vanessa Schmitt
2019-07-24 17:04:38 -07:00
committed by Jeremy Elbourn
parent f23a56a90d
commit 67532dbbb8
@@ -70,9 +70,13 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn
super.ngAfterContentInit();
if (this.removeIcon) {
// removeIcon has tabIndex 0 for regular chips, but should only be focusable by
// the GridFocusKeyManager for row chips.
this.removeIcon.tabIndex = -1;
// Defer setting the value in order to avoid the "Expression
// has changed after it was checked" errors from Angular.
setTimeout(() => {
// removeIcon has tabIndex 0 for regular chips, but should only be focusable by
// the GridFocusKeyManager for row chips.
this.removeIcon.tabIndex = -1;
});
}
}