Skip to content

Commit e7fd946

Browse files
committed
[Select] Add aria-disabled attribute
1 parent 078fd1e commit e7fd946

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/material-ui/src/Select/Select.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,18 @@ describe('<Select />', () => {
361361
expect(getByRole('button')).not.to.have.attribute('aria-expanded');
362362
});
363363

364+
it('sets aria-disabled="true" when component is disabled', () => {
365+
const { getByRole } = render(<Select disabled value="" />);
366+
367+
expect(getByRole('button')).to.have.attribute('aria-disabled', 'true');
368+
});
369+
370+
specify('aria-disabled is not present if component is not disabled', () => {
371+
const { getByRole } = render(<Select disabled={false} value="" />);
372+
373+
expect(getByRole('button')).not.to.have.attribute('aria-disabled');
374+
});
375+
364376
it('indicates that activating the button displays a listbox', () => {
365377
const { getByRole } = render(<Select value="" />);
366378

packages/material-ui/src/Select/SelectInput.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
324324
data-mui-test="SelectDisplay"
325325
tabIndex={tabIndex}
326326
role="button"
327+
aria-disabled={disabled ? 'true' : undefined}
327328
aria-expanded={open ? 'true' : undefined}
328329
aria-haspopup="listbox"
329330
aria-label={ariaLabel}

0 commit comments

Comments
 (0)