Skip to content
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

fix(material-experimental/mdc-chips): fix changed after checked error when restoring focus to input #24243

Merged
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
9 changes: 3 additions & 6 deletions src/material-experimental/mdc-chips/chip-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ export class MatChipGrid
this._chips.forEach(chip => chip.primaryAction._updateTabindex(-1));
this._chips.first.focus();
} else {
this._focusInput();
// Delay until the next tick, because this can cause a "changed after checked"
// error if the input does something on focus (e.g. opens an autocomplete).
Promise.resolve().then(() => this._chipInput.focus());
}

this.stateChanges.next();
Expand Down Expand Up @@ -482,9 +484,4 @@ export class MatChipGrid

this._lastDestroyedChipIndex = null;
}

/** Focus input element. */
private _focusInput() {
this._chipInput.focus();
}
}