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

[Select] Set aria-required & aria-invalid on combobox instead of hidden input #44731

Merged
merged 5 commits into from
Dec 16, 2024

Conversation

ben-pomelo
Copy link
Contributor

@ben-pomelo ben-pomelo commented Dec 11, 2024

This PR fixes #44740 which causes the screen reader to fail to identify Select components that are "Required" or are in an error state.

With this fix, this is what the screen reader reports:
image

image

@mui-bot
Copy link

mui-bot commented Dec 11, 2024

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against b539501

@ben-pomelo ben-pomelo changed the title MUI Select Accessibility: Put aria-required and aria-invalid on the combobox div to fix accessibility issues. [Select] Accessibility fixes to pipe aria-required and aria-invalid onto the appropriate element Dec 11, 2024
@ben-pomelo ben-pomelo changed the title [Select] Accessibility fixes to pipe aria-required and aria-invalid onto the appropriate element [Select] Accessibility fixes to wire aria-required and aria-invalid onto the appropriate element Dec 11, 2024
@ben-pomelo ben-pomelo marked this pull request as ready for review December 11, 2024 20:04
@mj12albert mj12albert added accessibility a11y component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Dec 12, 2024
@mj12albert mj12albert changed the title [Select] Accessibility fixes to wire aria-required and aria-invalid onto the appropriate element [Select] Set aria-required & aria-invalid on combobox instead of hidden input Dec 12, 2024
Copy link
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

@ben-pomelo Thanks for working on this ~

Would you mind also adding a simple test each for aria-required/aria-invalid here as well (highlighted lines as a reference)

@mj12albert mj12albert self-assigned this Dec 12, 2024
@ben-pomelo
Copy link
Contributor Author

ben-pomelo commented Dec 12, 2024

@mj12albert Thanks for pointing me to the tests, I added a few tests, including:

  1. Sets aria-required="true" when component is required
  2. Sets required attribute in input when component is required
  3. Sets aria-invalid="true" when component is in the error state

PTAL!

@ben-pomelo ben-pomelo force-pushed the select-sets-aria-required branch from 8d4a9a7 to 17e2574 Compare December 12, 2024 19:06
@ben-pomelo ben-pomelo force-pushed the select-sets-aria-required branch from 17e2574 to 522d09f Compare December 12, 2024 19:10
Copy link
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@mj12albert mj12albert added the bug 🐛 Something doesn't work label Dec 16, 2024
@mj12albert mj12albert merged commit 3baba19 into mui:master Dec 16, 2024
20 checks passed
@ben-pomelo ben-pomelo deleted the select-sets-aria-required branch December 16, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y bug 🐛 Something doesn't work 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] Required and Error states not correctly configured for screen readers
3 participants