Skip to content

Commit

Permalink
[Select] Add aria-disabled attribute (#20432)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbien authored Apr 6, 2020
1 parent 27ada70 commit 52b80a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/material-ui/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ describe('<Select />', () => {
expect(getByRole('button')).not.to.have.attribute('aria-expanded');
});

it('sets aria-disabled="true" when component is disabled', () => {
const { getByRole } = render(<Select disabled value="" />);

expect(getByRole('button')).to.have.attribute('aria-disabled', 'true');
});

specify('aria-disabled is not present if component is not disabled', () => {
const { getByRole } = render(<Select disabled={false} value="" />);

expect(getByRole('button')).not.to.have.attribute('aria-disabled');
});

it('indicates that activating the button displays a listbox', () => {
const { getByRole } = render(<Select value="" />);

Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
data-mui-test="SelectDisplay"
tabIndex={tabIndex}
role="button"
aria-disabled={disabled ? 'true' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-haspopup="listbox"
aria-label={ariaLabel}
Expand Down

0 comments on commit 52b80a0

Please sign in to comment.