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

Detect event.target.matches(':hover') in useFocus onBlur handler #2791

Open
aiktb opened this issue Feb 12, 2024 · 2 comments · May be fixed by #2809
Open

Detect event.target.matches(':hover') in useFocus onBlur handler #2791

aiktb opened this issue Feb 12, 2024 · 2 comments · May be fixed by #2809

Comments

@aiktb
Copy link

aiktb commented Feb 12, 2024

Describe the bug

I am using Listbox component of headlessui, in simple words, when I click on Listbox.Button which is used to open Listbox.Options, the focus will be moved to Listbox.Options programmatically, but At this time, the mouse is still on Listbox.Button, which will trigger the onBlur event defined by useFocus, causing the ToolTip to disappear. As the mouse continues to move on Listbox.Button, the ToolTip will reappear until the mouse leaves the ToolTip.

This is weird, I hope to be able to add logic similar to the following to useFocus:

onBlur(event) {
   if (event.target.matches(':hover')) {
     return;
   }
}

A new option for useFocus can be introduced to solve this issue. If you are willing to provide information on how to name and default value for this option, I would be happy to open a PR for this.

To Reproduce

Screenshots

reprod.mp4

Expected behavior

Screenshots

hope.mp4

Context:

  • OS: Windows 11
  • Browser: Chrome@121.0.6167.161
  • Version "@floating-ui/react": "^0.26.7",
@atomiks
Copy link
Collaborator

atomiks commented Feb 12, 2024

Are there cases where you wouldn't want this? Would be better to simply not have an option at all if possible.

@aiktb
Copy link
Author

aiktb commented Feb 12, 2024

Are there cases where you wouldn't want this? Would be better to simply not have an option at all if possible.

No, you're right, but I don't know if that would break anything.

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