Skip to content

Commit ebda4de

Browse files
authored
fix(material-experimental/chips): fix empty check when no chips (#20025)
* fix(material-experimental/chips): fix empty check when no chips * same for chipset * check for input too
1 parent 0d43581 commit ebda4de

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn
154154
* Implemented as part of MatFormFieldControl.
155155
* @docs-private
156156
*/
157-
get empty(): boolean { return this._chipInput.empty && this._chips.length === 0; }
157+
get empty(): boolean {
158+
return (!this._chipInput || this._chipInput.empty) &&
159+
(!this._chips || this._chips.length === 0);
160+
}
158161

159162
/** The ARIA role applied to the chip grid. */
160163
get role(): string | null { return this.empty ? null : 'grid'; }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit
193193

194194
/** Checks whether any of the chips is focused. */
195195
protected _hasFocusedChip() {
196-
return this._chips.some(chip => chip._hasFocus);
196+
return this._chips && this._chips.some(chip => chip._hasFocus);
197197
}
198198

199199
/** Syncs the chip-set's state with the individual chips. */

0 commit comments

Comments
 (0)