Skip to content

Commit

Permalink
[material-ui][Select] Aria-controls references invalid id when not ex…
Browse files Browse the repository at this point in the history
…panded #43876
  • Loading branch information
siddhantantil39 committed Jan 2, 2025
1 parent a491dc2 commit 6385301
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ describe('<Select />', () => {
expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-controls', listboxId);
});

it('indicates that input element has combobox role and aria-controls set to "" when in a non-open state', () => {
const { getByRole } = render(<Select open={false} value="" />);
expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-controls', '');
});

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

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
ref={handleDisplayRef}
tabIndex={tabIndex}
role="combobox"
aria-controls={listboxId}
aria-controls={open ? listboxId : ''}
aria-disabled={disabled ? 'true' : undefined}
aria-expanded={open ? 'true' : 'false'}
aria-haspopup="listbox"
Expand Down

0 comments on commit 6385301

Please sign in to comment.