-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Clicking Label does not open file picker when used in a Field with an Input type="file" #3680
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
Comments
Hello @EPurwanto The core issue is that Headless UI’s Additionally, the component always applies aria-labelledby, even when it’s empty. According to the ARIA in HTML spec and accessible name computation spec, this overrides the implicit htmlFor → id linkage, further breaking expected behavior. Limitations:
Workaround (which you are already aware, sorry, not a fix 😓 ):For file uploads, use standard HTML elements: <label htmlFor="file-upload">Upload</label>
<input id="file-upload" type="file" /> This ensures native interaction is preserved. Hope this helps others running into the same limitation or at least describes the cause. Edit: neglected to tag OP Update: Even with a native |
Hey! This should be fixed by #3707, and will be available in the next release. You can already try it using:
|
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
2.2.1
What browser are you using?
Tested in Chrome and Firefox
Reproduction URL
https://codesandbox.io/p/devbox/headless-ui-file-label-v5rlnq
The structure is just this:
Describe your issue
Clicking on a
Label
component that is attached to anInput
element of type "file" does not open the file picker. This is different to a standard HTML<label>
, which will open the file picker when clicked, both with a standard<input>
element and the Headless UIInput
component.The text was updated successfully, but these errors were encountered: