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

aria-describedby not respected #5562

Open
aakashsigdel opened this issue Feb 16, 2023 · 3 comments · May be fixed by #5563
Open

aria-describedby not respected #5562

aakashsigdel opened this issue Feb 16, 2023 · 3 comments · May be fixed by #5563
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet

Comments

@aakashsigdel
Copy link

Are you reporting a bug or runtime error? -> BUG

react-select doesn't respect aria-describedby as prop. This results in for errors not being pronounced by screen readers when focusing back on the field.

    <AsyncSelect
      onChange={handleSelect}
      loadOptions={loadOptions}
      placeholder={placeholder}
      inputId={id}
      aria-describedby="id-of-another-element"
    />

Example:
https://codesandbox.io/s/react-select-v5-sandbox-forked-i1vu1l

@aakashsigdel aakashsigdel added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Feb 16, 2023
@aakashsigdel aakashsigdel linked a pull request Feb 16, 2023 that will close this issue
@wbolduc
Copy link

wbolduc commented Jun 28, 2023

Bit of a workaround for right now

const Input = (props: InputProps) => {
	const passed_describedby = props.selectProps["aria-describedby"];
	const describedby =
		props["aria-describedby"] +
		(passed_describedby ? " " + passed_describedby : "");
	return <components.Input {...props} aria-describedby={describedby} />;
};

Which you can plug into your Select with

<ReactSelect
	components={{
		Input,
	}}
/>

This works okay because describedby accepts multiple ids. If you are using describedby to identify your errors your resolved description ends up looking like this "Select... Required" Which I think is okay

@cabillin
Copy link

+1 on this being an issue that I'd like to see fixed

Thanks for the workaround @wbolduc!

@prathamesh-voltup
Copy link

Thank you! @wbolduc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants