Skip to content

Commit 67532db

Browse files
vanessanschmittjelbourn
authored andcommitted
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.
1 parent f23a56a commit 67532db

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/material-experimental/mdc-chips/chip-row.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn
7070
super.ngAfterContentInit();
7171

7272
if (this.removeIcon) {
73-
// removeIcon has tabIndex 0 for regular chips, but should only be focusable by
74-
// the GridFocusKeyManager for row chips.
75-
this.removeIcon.tabIndex = -1;
73+
// Defer setting the value in order to avoid the "Expression
74+
// has changed after it was checked" errors from Angular.
75+
setTimeout(() => {
76+
// removeIcon has tabIndex 0 for regular chips, but should only be focusable by
77+
// the GridFocusKeyManager for row chips.
78+
this.removeIcon.tabIndex = -1;
79+
});
7680
}
7781
}
7882

0 commit comments

Comments
 (0)