Skip to content

fix(material-experimental/chips): fix empty check when no chips #20025

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

Merged
merged 3 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/material-experimental/mdc-chips/chip-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn
* Implemented as part of MatFormFieldControl.
* @docs-private
*/
get empty(): boolean { return this._chipInput.empty && this._chips.length === 0; }
get empty(): boolean {
return (!this._chipInput || this._chipInput.empty) &&
(!this._chips || this._chips.length === 0);
}

/** The ARIA role applied to the chip grid. */
get role(): string | null { return this.empty ? null : 'grid'; }
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-chips/chip-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit

/** Checks whether any of the chips is focused. */
protected _hasFocusedChip() {
return this._chips.some(chip => chip._hasFocus);
return this._chips && this._chips.some(chip => chip._hasFocus);
}

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