From 67532dbbb8a14dfdca2134b506b6269d76700516 Mon Sep 17 00:00:00 2001 From: Vanessa Schmitt Date: Wed, 24 Jul 2019 17:04:38 -0700 Subject: [PATCH] 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. --- src/material-experimental/mdc-chips/chip-row.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/material-experimental/mdc-chips/chip-row.ts b/src/material-experimental/mdc-chips/chip-row.ts index fb2a1841acd..87ddbb2ab70 100644 --- a/src/material-experimental/mdc-chips/chip-row.ts +++ b/src/material-experimental/mdc-chips/chip-row.ts @@ -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; + }); } }