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] Improve a11y by adding combobox role and aria-controls attribute #38785

Merged
merged 9 commits into from
Sep 27, 2023
8 changes: 4 additions & 4 deletions packages/mui-material/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ describe('<Select />', () => {
describe('prop: defaultOpen', () => {
it('should be open on mount', () => {
const { getByRole } = render(<Select defaultOpen value="" />);
expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-expanded', 'true');
expect(getByRole('combobox')).to.have.attribute('aria-expanded', 'true');
});
});

Expand Down Expand Up @@ -439,7 +439,7 @@ describe('<Select />', () => {
// technically matter. This is only here in case we keep the rest accessible
const { getByRole } = render(<Select open value="" />);

expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-expanded', 'true');
expect(getByRole('combobox')).to.have.attribute('aria-expanded', 'true');
});

specify('ARIA 1.2: aria-expanded="false" if the listbox isn\'t displayed', () => {
Expand Down Expand Up @@ -482,7 +482,7 @@ describe('<Select />', () => {
const { getByRole } = render(<Select open value="" />);
const listboxId = getByRole('listbox').id;

expect(getByRole('combobox', { hidden: true })).to.have.attribute('aria-controls', listboxId);
DiegoAndai marked this conversation as resolved.
Show resolved Hide resolved
expect(getByRole('combobox')).to.have.attribute('aria-controls', listboxId);
});

specify('the listbox is focusable', () => {
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('<Select />', () => {
);

const paper = getByTestId('paper');
const selectButton = getByRole('combobox', { hidden: true });
const selectButton = getByRole('combobox');

expect(paper.style).to.have.property('minWidth', `${selectButton.clientWidth}px`);
});
Expand Down