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

Ignore mouse move/leave events when the cursor hasn’t moved #2069

Merged
merged 12 commits into from Dec 7, 2022

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Dec 5, 2022

A mouse enter / leave event where the cursor hasn’t moved could only happen because the container moved under the cursor. This is typically the result of scrolling the parent container (but could because by other move-related situations as well, if you're moving things around with JS for instance).

Some browsers (like Chrome) will prevent these events from firing when a scroll would've caused them; however, Safari isn't smart enough to do this (or maybe it's an intentional decision — not sure).

Regardless, this is not a desirable behavior because when using the up/down arrows to move through a list the mouse move event will trigger if it happens to be in the area where an option would move to causing the focus to move to an option other than the one you intended.

@RobinMalfait pls tell me this makes sense lol

Should fix this once things are merged, tagged, and updated: tailwindlabs/tailwindui-issues#1378

@vercel
Copy link

vercel bot commented Dec 5, 2022

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

Name Status Preview Updated
headlessui-react ✅ Ready (Inspect) Visit Preview Dec 7, 2022 at 6:45PM (UTC)
headlessui-vue ✅ Ready (Inspect) Visit Preview Dec 7, 2022 at 6:45PM (UTC)

@thecrypticace
Copy link
Contributor Author

@RobinMalfait I've tweaked the implementation slightly with how it bypasses checks during tests. It now only does so for the pointer event calls in JSDOM. I use an env var to do this which required a tweak to the build script to make sure it was removed at compile time for release builds.

Any worries with this approach? If not them I'll merge this in.

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.

None yet

2 participants