Skip to content

Commit

Permalink
fix(material/select): NVDA reading out table when opening select on C…
Browse files Browse the repository at this point in the history
…hrome

The `mat-select` trigger element has an `aria-owns` pointing to the overlay and `display: inline-table` in its CSS. The combination of these two causes Chrome to infer the element as a `table` which results in NVDA reading out "table" any time a select is opened.

These changes resolve the issue by using flexbox to lay out the select trigger instead.

Fixes angular#21480.
  • Loading branch information
crisbeto committed Aug 25, 2021
1 parent 5ba40c1 commit 51474d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/material-experimental/mdc-select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ $scale: 0.75 !default;
}

.mat-mdc-select-trigger {
display: inline-table;
display: inline-flex;
align-items: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
width: 100%;

.mat-mdc-select-disabled & {
@include vendor-prefixes.user-select(none);
Expand All @@ -37,8 +39,6 @@ $scale: 0.75 !default;
}

.mat-mdc-select-value {
display: table-cell;
max-width: 0;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -52,8 +52,10 @@ $scale: 0.75 !default;
}

.mat-mdc-select-arrow-wrapper {
display: table-cell;
vertical-align: middle;
height: 24px;
flex-shrink: 0;
display: inline-flex;
align-items: center;

// When used in a box appearance form-field the arrow should be shifted up 40%.
.mat-form-field-appearance-fill & {
Expand Down
12 changes: 7 additions & 5 deletions src/material/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ $placeholder-arrow-space: 2 * ($arrow-size + $arrow-margin);
}

.mat-select-trigger {
display: inline-table;
display: inline-flex;
align-items: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
width: 100%;

.mat-select-disabled & {
@include vendor-prefixes.user-select(none);
Expand All @@ -31,8 +33,6 @@ $placeholder-arrow-space: 2 * ($arrow-size + $arrow-margin);
}

.mat-select-value {
display: table-cell;
max-width: 0;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
Expand All @@ -44,8 +44,10 @@ $placeholder-arrow-space: 2 * ($arrow-size + $arrow-margin);
}

.mat-select-arrow-wrapper {
display: table-cell;
vertical-align: middle;
height: 16px;
flex-shrink: 0;
display: inline-flex;
align-items: center;

// When used in a box appearance form-field the arrow should be shifted up 50%.
.mat-form-field-appearance-fill & {
Expand Down

0 comments on commit 51474d0

Please sign in to comment.