Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/dev-app/chips/chips-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h4>Single selection</h4>

<h4>Multi selection</h4>

<mat-chip-listbox multiple="true" [disabled]="disabledListboxes">
<mat-chip-listbox multiple="true" [disabled]="disabledListboxes" hideSelectionIndicator>
@for (hint of restaurantHints; track hint) {
<mat-chip-option [selected]="hint.selected">
@if (listboxesWithAvatar) {
Expand Down
13 changes: 13 additions & 0 deletions src/material/chips/chip-listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ export class MatChipListbox
private _hideSingleSelectionIndicator: boolean =
this._defaultOptions?.hideSingleSelectionIndicator ?? false;

/** Whether checkmark indicators for single and multiple selection are hidden. */
@Input({transform: booleanAttribute})
get hideSelectionIndicator(): boolean {
return this._hideSelectionIndicator;
}
set hideSelectionIndicator(value: boolean) {
this._hideSelectionIndicator = value;
this._syncListboxProperties();
}
private _hideSelectionIndicator: boolean =
this._defaultOptions?.hideSelectionIndicator ?? false;

/** Combined stream of all of the child chips' selection change events. */
get chipSelectionChanges(): Observable<MatChipSelectionChange> {
return this._getChipStream<MatChipSelectionChange, MatChipOption>(chip => chip.selectionChange);
Expand Down Expand Up @@ -369,6 +381,7 @@ export class MatChipListbox
chip._chipListMultiple = this.multiple;
chip.chipListSelectable = this._selectable;
chip._chipListHideSingleSelectionIndicator = this.hideSingleSelectionIndicator;
chip._chipListHideSelectionIndicator = this.hideSelectionIndicator;
chip._changeDetectorRef.markForCheck();
});
});
Expand Down
8 changes: 8 additions & 0 deletions src/material/chips/chip-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export class MatChipOption extends MatChip implements OnInit {
_chipListHideSingleSelectionIndicator: boolean =
this._defaultOptions?.hideSingleSelectionIndicator ?? false;

/** Whether the chip list hides selection indicator for single and multiple selection. */
_chipListHideSelectionIndicator: boolean =
this._defaultOptions?.hideSelectionIndicator ?? false;

/**
* Whether or not the chip is selectable.
*
Expand Down Expand Up @@ -188,6 +192,10 @@ export class MatChipOption extends MatChip implements OnInit {
return true;
}

if (this._chipListHideSelectionIndicator) {
return false;
}

// The checkmark graphic communicates selected state for both single-select and multi-select.
// Include checkmark in single-select to fix a11y issue where selected state is communicated
// visually only using color (#25886).
Expand Down
3 changes: 3 additions & 0 deletions src/material/chips/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export interface MatChipsDefaultOptions {
/** Whether icon indicators should be hidden for single-selection. */
hideSingleSelectionIndicator?: boolean;

/** Whether icon indicators should be hidden for multiple and single selection */
hideSelectionIndicator?: boolean;

/** Whether the chip input should be interactive while disabled by default. */
inputDisabledInteractive?: boolean;
}
Expand Down
Loading