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

[React] Menu component taking over focus on close #1641

Closed
breadadams opened this issue Jul 4, 2022 · 1 comment · Fixed by #1782
Closed

[React] Menu component taking over focus on close #1641

breadadams opened this issue Jul 4, 2022 · 1 comment · Fixed by #1782
Assignees

Comments

@breadadams
Copy link

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.6.5

What browser are you using?

Chrome w/ macOS Voice Over, and Chrome Screen Reader

Reproduction URL

https://stackblitz.com/edit/headlessui-dialog-a11y-bug

(If a git repo is required too just let me know)

Describe your issue

When a Menu component contains an option that triggers a Dialog, screen readers do not detect the opening of the dialog component.

This appears to be due to the fact that Menu.Items returns focus to the Menu.Button when it closes, and therefore the screen reader instead reads that focus action.

Our workaround currently has been to wait for the next tick before opening the dialog:

// before
<Menu.Item><button onClick={() => setIsOpen(true)} ... /></Menu.Item>

// after 
<Menu.Item><button onClick={() => setTimeout(() => setIsOpen(true), 0)} ... /></Menu.Item>
@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

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

You can already try it using:

  • npm install @headlessui/react@insiders.
  • npm install @headlessui/vue@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
2 participants