Skip to content

Commit

Permalink
fix(material/chips): add selected indication in high contrast mode (#…
Browse files Browse the repository at this point in the history
…23828)

Currently the single-selection chip shows that it's selected by changing its background color, but that doesn't work in high contrast mode. These changes add a thicker outline when the chip is selected.

(cherry picked from commit 2c637d3)
  • Loading branch information
crisbeto authored and amysorto committed Nov 9, 2021
1 parent 2b99632 commit 15237f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/material-experimental/mdc-chips/chip-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class MatChipSelectionChange {
'[class.mat-mdc-chip-with-avatar]': 'leadingIcon',
'[class.mat-mdc-chip-with-trailing-icon]': 'trailingIcon || removeIcon',
'[class.mat-mdc-chip-selected]': 'selected',
'[class.mat-mdc-chip-multiple]': '_chipListMultiple',
'[id]': 'id',
'[tabIndex]': 'tabIndex',
'[attr.disabled]': 'disabled || null',
Expand Down
8 changes: 8 additions & 0 deletions src/material-experimental/mdc-chips/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ $chip-margin: 4px;
}
}

// Single-selection chips show their selected state using a background color which won't be visible
// in high contrast mode. This isn't necessary in multi-selection since there's a checkmark.
.mat-mdc-chip-selected:not(.mat-mdc-chip-multiple) {
@include a11y.high-contrast(active, off) {
outline-width: 3px;
}
}

.mat-mdc-chip-row-focusable-text-content,
.mat-mdc-chip-remove-icon {
display: flex;
Expand Down
5 changes: 5 additions & 0 deletions src/material/chips/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ $chip-remove-size: 18px;
// Use 2px here since the dotted outline is a little thinner.
outline: dotted 2px;
}

// Seleted state is shown using a background color which isn't visible in high contrast mode.
&.mat-chip-selected {
outline-width: 3px;
}
}

&.mat-chip-disabled {
Expand Down

0 comments on commit 15237f8

Please sign in to comment.