Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][Select] Do not set aria-controls when closed #44919

Merged
merged 8 commits into from
Jan 7, 2025
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 @@ -517,6 +517,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', () => {
siddhantantil39 marked this conversation as resolved.
Show resolved Hide resolved
const { getByRole } = render(<Select open={false} value="" />);
expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-controls', '');
siddhantantil39 marked this conversation as resolved.
Show resolved Hide resolved
});

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 @@ -497,7 +497,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
ref={handleDisplayRef}
tabIndex={tabIndex}
role="combobox"
aria-controls={listboxId}
aria-controls={open ? listboxId : undefined}
aria-disabled={disabled ? 'true' : undefined}
aria-expanded={open ? 'true' : 'false'}
aria-haspopup="listbox"
Expand Down
Loading