-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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] Prop aria-describedby is passed down to hidden input element #24019
Comments
@HVish Thanks for reporting the issue. I could reproduce on VoiceOver with this demo https://next.material-ui.com/components/text-fields/#select. It works with the native select but fails with the nonnative implementation. What do you think about this fix? Do you want to work on a pull request? :) diff --git a/docs/src/pages/components/text-fields/SelectTextFields.tsx b/docs/src/pages/components/text-fields/SelectTextFields.tsx
index 124b6085cf..5f00b6278b 100644
--- a/docs/src/pages/components/text-fields/SelectTextFields.tsx
+++ b/docs/src/pages/components/text-fields/SelectTextFields.tsx
@@ -33,7 +33,7 @@ const useStyles = makeStyles((theme: Theme) =>
}),
);
-export default function MultilineTextFields() {
+export default function SelectTextFields() {
const classes = useStyles();
const [currency, setCurrency] = React.useState('EUR');
diff --git a/packages/material-ui/src/Select/SelectInput.js b/packages/material-ui/src/Select/SelectInput.js
index 34244bb0ef..4ba999d576 100644
--- a/packages/material-ui/src/Select/SelectInput.js
+++ b/packages/material-ui/src/Select/SelectInput.js
@@ -28,6 +28,7 @@ function isEmpty(display) {
*/
const SelectInput = React.forwardRef(function SelectInput(props, ref) {
const {
+ 'aria-describedby': ariaDescribedby,
'aria-label': ariaLabel,
autoFocus,
autoWidth,
@@ -367,6 +368,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
aria-haspopup="listbox"
aria-label={ariaLabel}
aria-labelledby={[labelId, buttonId].filter(Boolean).join(' ') || undefined}
+ aria-describedby={ariaDescribedby}
onKeyDown={handleKeyDown}
onMouseDown={disabled || readOnly ? null : handleMouseDown}
onBlur={handleBlur}
@@ -439,6 +441,10 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
});
SelectInput.propTypes = {
+ /**
+ * @ignore
+ */
+ 'aria-describedby': PropTypes.string,
/**
* @ignore
*/ At first, I got confused with the difference with |
@oliviertassinari Of course! Actually I was about to send the pull request :D I have one more question. Like other form components could we have
So I was wondering if we could do some work around with non-native select component? |
I'm not familiar with this |
I am trying to use
Select
component with accessibility support. It works pretty well except for the usage withFormHelperText
. When the select toggle button is focused the screen reader does not read the contents ofFormHelperText
. I have also tried using theTextField
component withselect
prop for better support as mentioned in docs.Current Behavior 😯
The screen reader does not reads the helper text provided using
aria-describedby
prop toSelect
component or simply by passingid
prop toTextField
component withselect
prop. Instead the prop is passed down to the hidden (aria-hidden) input element. I have narrowed down it to following piece of code:https://github.com/mui-org/material-ui/blob/174b64f8a3adffb8df3c13285f4edc2437a8547a/packages/material-ui/src/TextField/TextField.js#L176
https://github.com/mui-org/material-ui/blob/174b64f8a3adffb8df3c13285f4edc2437a8547a/packages/material-ui/src/Select/SelectInput.js#L398
Expected Behavior 🤔
It should pass the
aria-describedby
prop to wrapperdiv
of select component. May be in following line:https://github.com/mui-org/material-ui/blob/174b64f8a3adffb8df3c13285f4edc2437a8547a/packages/material-ui/src/Select/SelectInput.js#L372
Steps to Reproduce 🕹
I am implementing it as follows:
Context 🔦
I would like to make screen readers read the helper text for form validation purpose.
Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: