Skip to content

Commit 292c99c

Browse files
feat(material/chips): update chip-list describedby to match input
Fixes ExpressionChangedAfterItHasBeenCheckedError that occurs when chip-lists are content-projected into a mat-form-field
1 parent fed8fae commit 292c99c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/material/chips/chip-list.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export class MatChipListChange {
7878
exportAs: 'matChipList',
7979
host: {
8080
'[attr.tabindex]': 'disabled ? null : _tabIndex',
81-
'[attr.aria-describedby]': '_ariaDescribedby || null',
8281
'[attr.aria-required]': 'role ? required : null',
8382
'[attr.aria-disabled]': 'disabled.toString()',
8483
'[attr.aria-invalid]': 'errorState',
@@ -144,9 +143,6 @@ export class MatChipList
144143
/** Uid of the chip list */
145144
_uid: string = `mat-chip-list-${nextUniqueId++}`;
146145

147-
/** The aria-describedby attribute on the chip list for improved a11y. */
148-
_ariaDescribedby: string;
149-
150146
/** Tab index for the chip list. */
151147
_tabIndex = 0;
152148

@@ -455,7 +451,11 @@ export class MatChipList
455451
* @docs-private
456452
*/
457453
setDescribedByIds(ids: string[]) {
458-
this._ariaDescribedby = ids.join(' ');
454+
if (ids.length) {
455+
this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));
456+
} else {
457+
this._elementRef.nativeElement.removeAttribute('aria-describedby');
458+
}
459459
}
460460

461461
// Implemented as part of ControlValueAccessor.

0 commit comments

Comments
 (0)