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

[DOCS]: Listbox states that "Enter" on button will open the listbox #3216

Closed
JakeDluhy opened this issue May 17, 2024 · 1 comment
Closed
Assignees

Comments

@JakeDluhy
Copy link

Not sure if this is a bug or a docs issue, but the docs for the Listbox in v2 state that "Enter" will open the Listbox, but I was not finding that to be the case in my application. Looking at the code it looks like that is not the case in the code either: https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/listbox/listbox.tsx#L763

So I think the docs need to be updated?

@RobinMalfait RobinMalfait self-assigned this May 29, 2024
@RobinMalfait
Copy link
Collaborator

Hey!

Yep the docs were wrong, we changed this behavior for Headless UI v2. If you focus the ListboxButton and press enter (while the Listbox is closed) then the parent form (if any) will submit.

The reason for this change is so that every form-like component can submit the form when pressing enter. If you want to open the Listbox with the keyboard, then you can still use the ⬆︎, ⬇︎ and space keys.

This has been fixed and the docs have been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants