fix(hover-card): keep open while pointer crosses gap between trigger and content - #3209
fix(hover-card): keep open while pointer crosses gap between trigger and content#3209Arman-Luthra wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 68dba5a The changes in this PR will be included in the next version bump. This PR includes changesets to release 86 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Took a closer look at this one. The fix and tests hold up: the default gutter (8px, from Two small nits, nothing blocking:
Looks good to merge otherwise. |
Closes #3181
📝 Description
When
positioning.gutter(or anoffset) creates a visual gap between the trigger and the content, moving the pointer across that gap can close the hover card, because the pointer briefly hovers neither element. This PR adds a grace area (safe polygon) between the trigger and the content, similar to Floating UI'ssafePolygonand Radix's hover card.⛳️ Current behavior (updates)
pointerleave, the machine entersclosingand closes aftercloseDelay, regardless of where the pointer is heading.closeDelay, so users are forced to increasecloseDelayglobally to make interactive hover cards usable with a gutter.🚀 New behavior
getElementPolygon/isPointInPolygonfrom@zag-js/rect-utils, the same primitives the menu machine uses for its submenu intent polygon).CLOSE_DELAYexpiry is ignored, so the card stays open during the traversal no matter how smallcloseDelayis.closingstate re-enters and the regularcloseDelaycountdown restarts — so moving away still closes the card with the usual delay.Interaction with
closeDelay: the delay is effectively paused while the pointer is in transit between the two elements, and restarts once the pointer leaves the corridor. Entering the content/trigger cancels the close as before.💣 Is this a breaking change (Yes/No):
No. Public API is unchanged; the grace area is internal (
refs). The only new dependency is the existing workspace package@zag-js/rect-utils.📝 Additional Information
main, pass with this fix), plus a test asserting the card still closes when the pointer enters the gap and then veers away.closeDelaybehavior.