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

[insiders] Focus trapping broken with anchored, non-modal Listbox.Options inside Transition inside Dialog #3107

Closed
benface opened this issue Apr 18, 2024 · 4 comments · Fixed by #3112
Assignees

Comments

@benface
Copy link

benface commented Apr 18, 2024

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

0.0.0-insiders.9f44656

What browser are you using?

Chrome

Reproduction URL

https://codesandbox.io/p/sandbox/amazing-glitter-c7sdrr?file=%2Fsrc%2FApp.tsx

Describe your issue

Using only the keyboard, open the dialog and then the listbox inside it (sorry for the lack of styles). Notice how the options menu is not automatically focused. If you tab, the link after the listbox gets focused, and if you tab again, then the menu gets focused and the focus is trapped.

Notice that the issue does NOT happen if you:

  • remove the anchor or modal props from Listbox.Options
  • don't wrap the Listbox.Options in a Transition
  • don't wrap the Listbox in a Dialog
@benface benface changed the title [insiders] Focus trapping broken with Listbox inside Transition inside Dialog [insiders] Focus trapping broken with anchored Listbox.Options inside Transition inside Dialog Apr 18, 2024
@benface benface changed the title [insiders] Focus trapping broken with anchored Listbox.Options inside Transition inside Dialog [insiders] Focus trapping broken with anchored, non-modal Listbox.Options inside Transition inside Dialog Apr 18, 2024
@RobinMalfait
Copy link
Member

Hey!

Do you mind updating the CodeSandbox link or making it public. Currently seeing an error like this:
image

@benface
Copy link
Author

benface commented Apr 18, 2024

Side quest bug: if you remove modal={false}, clicking outside the listbox when it's open closes not just the listbox, but the dialog as well.

EDIT: I opened a new issue for it.

@benface
Copy link
Author

benface commented Apr 18, 2024

Ugh, sorry @RobinMalfait. 🤦‍♂️ Just made it public.

@RobinMalfait
Copy link
Member

Hey!

This should be fixed by #3112, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.

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

Successfully merging a pull request may close this issue.

2 participants