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
Custom labels for combobox are missing the htmlFor property #3139
Comments
Hi there! Thanks for getting back to me so quickly. Yes, the aria-labelledby on the input in my example looks good. But it’s also expected that the label will have a “for” property that points to the id of the input it labels since the input is not a child element of the label.
From https://www.w3.org/TR/html401/interact/forms.html#h-17.9.1
"This attribute explicitly associates the label being defined with another control. When present, the value of this attribute must be the same as the value of the id attribute of some other control in the same document. When absent, the label being defined is associated with the element's contents."
And if you run the WAVE (web accessibility evaluation) tool on the example page submitted in the issue, you’ll see an “orphaned form label” alert.
… On Apr 25, 2024, at 12:13 PM, Adam Wathan ***@***.***> wrote:
Hey! The label is associated with the input using aria-labelledby to make sure the label is properly announced to screen readers:
image.png (view on web)
Is there a specific issue you are seeing that we'd need to add htmlFor to solve?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.7.19
What browser are you using?
Chrome/Firefox
Reproduction URL
https://codesandbox.io/p/devbox/elastic-julien-97m3nj?file=%2Fsrc%2FApp.jsx%3A31%2C56
Describe your issue
When providing a custom label for a combobox, the rendered custom label is missing the htmlFor property which is needed for accessibility.
See examples at https://www.w3.org/WAI/GL/wiki/Using_aria-labelledby_to_concatenate_a_label_from_several_text_nodes
The text was updated successfully, but these errors were encountered: