Replies: 4 comments
-
Hey! Thank you for your question! The short answer is "copy & paste" issue, the longer answer is that we have to fix it but it isn't super straightforward due to the While I agree that the native The only downside in that example is that you can't click the "label" in the case when using the aria-labelledby, but in Headless UI this is a non-issue because we have a click listener for that since we also use that code where we can't immediately attach it to an |
Beta Was this translation helpful? Give feedback.
-
@RobinMalfait Thanks for the background on this! That makes sense with the In my testing with VoiceOver and NVDA, the input's accessible name is announced as expected, but various linting tools or validators might through a warning or error due to a lack of a |
Beta Was this translation helpful? Give feedback.
-
What reason can there be to use a p (or any other non-label element) as a label for an input? Given that there are no styling issues for labels, I know of no use case as to why any other element should be needed / allowed. One of the basic tenets of accessibility is to use semantic elements. The first rule of ARIA is to only use it when the functionality isn't available natively. As i said above: i see no use case that would necessitate the current complex solution over the very simple native HTML solution. As an aside: the component also allows for the lack of a label. I noticed that when looking at the example combobox' code (https://headlessui.com/react/combobox). That is also an accessibility violation. |
Beta Was this translation helpful? Give feedback.
-
Going to convert this to a discussion — agree it would be a nice improvement to use
One reasonable use-case for the <Combobox.Label as={MyCustomLabel}>...</Combobox.Label> I'm sure there are situations where it's useful to render it as a Right now every single component in the entire framework accepts an People are always going to find ways to do things you don't really want them to do with your library, so personally I don't try to be hyper-defensive with how I design APIs. Try to make doing things the right way easy, but ultimately give people sharp knives and let them make their own messes the same way you'd want someone to trust you to make your own messes. We can agree to disagree here if needed, it's just a free OSS library at the end of the day that you can choose to use or not use 🤷 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.5.0
What browser are you using?
Any
Reproduction URL
https://stackblitz.com/edit/nextjs-rfh5ei?file=pages%2Findex.js
Describe your issue
<Combobox.Label>
should auto-generate afor
attribute that matches theid
on the<Combobox.Input>
. Instead,<Combobox.Input>
usesaria-labelledby
, which points to theid
of the label.Is there a reason to use this approach instead of the native
for
attribute?Here's an example of the rendered markup:
And the expected markup:
Beta Was this translation helpful? Give feedback.
All reactions