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

Fix: tooltip closes while pointer is still inside trigger #1158

Merged

Conversation

anatolzak
Copy link
Contributor

closes #886

The reason issue #886 occurs is because clientX is smaller by 1 than triggerRect.left, which causes us to inaccurately "think" that the pointer is outside the trigger which causes the tooltip to close. This is due to sub-pixel rendering and rounding issues by the browser.

To make sure this doesn't happen, we now keep track of 2 extra variables isPointerInsideTrigger and isPointerInsideContent that are set on pointerenter and pointerleave for the trigger and content respectively. And isPointerInsideTrigger and isPointerInsideContent are taken into account in addition to pointInPolygon() when deciding whether the pointer is inside the tooltip area.

Before

Screen.Recording.2024-04-06.at.3.23.50.PM.mov

After

Screen.Recording.2024-04-06.at.3.22.58.PM.mov

Copy link

changeset-bot bot commented Apr 6, 2024

🦋 Changeset detected

Latest commit: 4aad946

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@melt-ui/svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@huntabyte huntabyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're an animal (in a good way)!

Copy link
Contributor

github-actions bot commented Apr 6, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
melt-ui ✅ Ready (View Log) Visit Preview 7df4d2b

@TGlide TGlide merged commit d66b831 into melt-ui:develop Apr 21, 2024
5 of 6 checks passed
This was referenced Apr 21, 2024
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.

🐛Bug: Tooltip with disableHoverableContent: true is glitchy
3 participants