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

Only restore focus to the Menu.Button if necessary when activating a Menu.Option #1782

Merged
merged 2 commits into from Aug 22, 2022

Conversation

RobinMalfait
Copy link
Collaborator

This PR will fix a bug where the focus was incorrectly moved to the Menu.Button even though the focus already moved. If you happen to open a Dialog then the focus would incorrectly be moved back to the Menu.Button. Instead we now check wether the focus was already moved, if that's the case then we don't return the focus to the Menu.Button.

Fixes: #1641

This will check whether the focus got moved to somewhere else or not
once we activate an item via click or pressing `enter`.

Pressing escape will still move focus to the Menu Button.
@vercel
Copy link

vercel bot commented Aug 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Aug 22, 2022 at 3:00PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Aug 22, 2022 at 3:00PM (UTC)

@manodrum
Copy link

also fixes #259

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 this pull request may close these issues.

[React] Menu component taking over focus on close
2 participants