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

Conversation

xulingzhihou
Copy link
Contributor

@xulingzhihou xulingzhihou commented Sep 3, 2023

Resolves: #35586

Changelog instructions

If your tests require selecting the triggering element by the "button" role, then you'll have to change it to use "combobox"

@mui-bot
Copy link

mui-bot commented Sep 3, 2023

Netlify deploy preview

https://deploy-preview-38785--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 1acf350

@zannager zannager added the component: select This is the name of the generic UI component, not the React module! label Sep 4, 2023
@zannager zannager requested a review from DiegoAndai September 4, 2023 10:43
@danilo-leal danilo-leal changed the title Improve Select Component a11y by adding combobox role and aria-controls attribute [material-ui][Select] Improve a11y by adding combobox role and aria-controls attribute Sep 5, 2023
@danilo-leal danilo-leal added accessibility a11y package: material-ui Specific to @mui/material labels Sep 5, 2023
@DiegoAndai
Copy link
Member

DiegoAndai commented Sep 5, 2023

Hey @xulingzhihou, thanks for working on this!

@xulingzhihou
Copy link
Contributor Author

xulingzhihou commented Sep 5, 2023

  • generate a unique id for the aria-controls attribute

@DiegoAndai thanks for your feedback. I am very new to this repo and I want to clarify something here:

  • what do you mean by "Native Select component"? which other components should I add the attributes to?
  • regarding the id, I noticed there is already an id assigned to Menu component, and aria-controls should "Identifies the element that serves as the popup" which in this case is the Menu

@DiegoAndai
Copy link
Member

@xulingzhihou thank you for taking an interest in contributing to Material UI 😊

what do you mean by "Native Select component"? which other components should I add the attributes to?

Sorry, I got confused. Don't consider my Native Select component comment 😅 I confused the SelectNativeInput here with NativeSelectInput, another component we use to render a native browser select.

regarding the id, I noticed there is already an id assigned to Menu component

The aria-controls ID should be the ID of the listbox element, and here we're referencing the menu root:

Screenshot 2023-09-06 at 12 36 18

Finally, I think the combobox role and aria-controls properties should go to the element that right now has an incorrect "button" role. For comparison, look at Base UI's Select.

I don't know why we have the hidden input 🤔

@mui/core, does anyone know the use of this element?

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 11, 2023

does anyone know the use of this element?

Form auto-fill support, Form post support

@DiegoAndai
Copy link
Member

@xulingzhihou let me know if you need help with the failing tests

@DiegoAndai
Copy link
Member

Hey @xulingzhihou, is this ready for review? 😊

Could you provide an example with the before and after to make this review easier? To do so, you can provide the same example in these different environments:

This should allow us to see the correct role and aria-controls attribute being applied. It would be perfect if you could do so with all components being affected (Select, TextField, TablePagination).

@xulingzhihou
Copy link
Contributor Author

Hey @xulingzhihou, is this ready for review? 😊

Could you provide an example with the before and after to make this review easier? To do so, you can provide the same example in these different environments:

This should allow us to see the correct role and aria-controls attribute being applied. It would be perfect if you could do so with all components being affected (Select, TextField, TablePagination).

@DiegoAndai yes it is ready for review!

Here are the examples requested:

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready to merge. There is just one last small change to clean up some comments fixed with this PR 🚀

To fix the Argos failures, we'll have to merge the updated master branch into this branch before merging the PR. Feel free to let me know if you need help with this.

Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge 🎉
Great work 🙌🏼
I'll merge as soon as the CI passes

@xulingzhihou
Copy link
Contributor Author

Ready to merge 🎉 Great work 🙌🏼 I'll merge as soon as the CI passes

Thank you for helping me with my first mui pr @DiegoAndai !!

@DiegoAndai DiegoAndai merged commit 572449d into mui:master Sep 27, 2023
6 checks passed
@xulingzhihou xulingzhihou deleted the xulingzhihou/fixSelectA11y branch October 3, 2023 20:03
return (
<React.Fragment>
<SelectSelect
ref={handleDisplayRef}
tabIndex={tabIndex}
role="button"
role="combobox"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be considered a breaking change, so it should be a minor version change instead of a patch change?
v5.14.11 -> v5.15.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! It's an a11y bug fix; the "button" role was incorrect, so I think it falls under a patch version. Also, this should keep functionality intact; tests should only be impacted by how the component is selected. Please let me know if this is not the case for you 😊

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit tests on the app that I'm working on broke because of this change when bumping MUI patch versions. Please do consider bumping the minor next time instead when making such a change

Copy link

@Lori-Becker Lori-Becker Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an absolutely awful decision. The notes on 5.14.12 did not detail that this would be a breaking change. It should have been called out immediately. I am working on an enterprise application with thousands of tests. Now they are all broken because of this one change that was supposedly "minor." How can we rely on a library that may break functionality on patch updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Lori-Becker and @mrharispe, I'm sorry for the inconvenience this might've caused. We will learn from this and be more careful moving forward. Thank you for using the library and providing feedback.

@LukasTy LukasTy mentioned this pull request Oct 19, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select] Improve implementation to align better with ARIA documentation
9 participants