Skip to content

Commit

Permalink
Improve Select Component a11y by adding combobox role and aria-contro…
Browse files Browse the repository at this point in the history
…ls attribute

Resolves: #35586
  • Loading branch information
Lingzhi Xu committed Sep 3, 2023
1 parent 31e2f14 commit 942de8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ describe('<Select />', () => {
expect(getByRole('listbox')).toBeVisible();
});

it('indicates that input element has combobox role and aria-controls set to id of popup', () => {
const { getByRole } = render(<Select open value="" />);

expect(getByRole('combobox')).to.have.attribute('aria-controls', 'menu-');
});

specify('the listbox is focusable', () => {
const { getByRole } = render(<Select open value="" />);

Expand Down
2 changes: 2 additions & 0 deletions packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
className={classes.nativeInput}
autoFocus={autoFocus}
ownerState={ownerState}
role="combobox"
aria-controls={`menu-${name || ''}`}
{...other}
/>
<SelectIcon as={IconComponent} className={classes.icon} ownerState={ownerState} />
Expand Down

0 comments on commit 942de8f

Please sign in to comment.