Skip to content

fix(core): keep ActionPanel submenu open when hovering into it - #17

Open
kinged007 wants to merge 1 commit into
buzinas:mainfrom
kinged007:fix/submenu-hover-close
Open

fix(core): keep ActionPanel submenu open when hovering into it#17
kinged007 wants to merge 1 commit into
buzinas:mainfrom
kinged007:fix/submenu-hover-close

Conversation

@kinged007

@kinged007 kinged007 commented Aug 11, 2026

Copy link
Copy Markdown

Fix: ActionPanel source submenu closes when moving the mouse into it

Fixes #16

Problem

In the element inspector's action panel, hovering a source entry opens the plugin submenu (code preview + "Add comment" / "Copy path" actions), but the submenu disappears as soon as the mouse moves into it — even while the pointer is still inside the popup. Clicking entries is also flaky ("buttons sometimes unclickable") because the menu can close before the click lands.

Root cause

The Submenu used DropdownMenu.Trigger with openOnHover, delay={0}, closeDelay={0}. Base UI's hover-close path is governed by floating-ui's safePolygon, which only keeps the popup open if the pointer travels through a narrow safe zone between the trigger and the popup:

  • The popup (up to ~480px wide, e.g. the folder-access prompt) is much taller and wider than the ~315px trigger entry, and when the viewport lacks room it flips to the opposite side (side="right" with collisionPadding).
  • The safe-polygon geometry is anchored once at the pointer-leave position and can be near-degenerate (the cursor point is offset by only POLYGON_BUFFER / 2 = 0.25px from the cursor), so any diagonal traversal or small vertical deviation while crossing the 4px gap exits the polygon and closes the menu — even though the pointer is about to enter (or is already inside) the popup's bounding box.
  • closeDelay={0} means any missed "landing" closes the menu immediately.

Fix

Replace the openOnHover/safePolygon close behavior with a standard hover-intent pattern that react-trace fully controls:

  • Controlled open state on the DropdownMenu.Root.
  • Open on hover/focus of the trigger; close with a 150ms grace period (SUBMENU_CLOSE_DELAY_MS) that is cancelled whenever the pointer is over the trigger or the popup.
  • Set the selected source (setSelectedSource) when opening via hover too — previously the hover-open path (which goes through the controlled open prop) never ran setSelectedSource, so the plugin action panels rendered an empty popup on the first hover until a click opened the menu through onOpenChange.

Verification

Reproduced the original bug headlessly against a dev server (popup closed 3px inside its edge while moving the mouse in), then verified the fix:

  • 25-step approach into the popup: stays open through every step (was closing at step ~24).
  • Fast single-jump move into the popup: stays open (was closing on the first move).
  • Fresh page load, first hover: popup opens at full size with content, stays open when moving in.

The ActionPanel source submenu used openOnHover with delay 0/closeDelay 0,
which relies on floating-ui's safePolygon hover-intent. The polygon
geometry is degenerate when the popup is taller/wider than its trigger and
flips to the opposite side, so the popup closes while the pointer is still
inside it (or while moving into it), making the action buttons hard to
click.

Replace with controlled open state and a standard hover-intent pattern:
a 150ms close grace period that is cancelled whenever the pointer is over
the trigger or the popup. Also set the selected source when opening via
hover so the plugin action panels (preview/comments) render on first open.
@kinged007 kinged007 changed the title fix(core): keep ActionPanel submenu open when hovering into it fix(core): keep ActionPanel submenu open and fully visible Aug 11, 2026
@kinged007
kinged007 force-pushed the fix/submenu-hover-close branch from c1cef50 to ab5bcc9 Compare August 11, 2026 21:59
@kinged007 kinged007 changed the title fix(core): keep ActionPanel submenu open and fully visible fix(core): keep ActionPanel submenu open when hovering into it Aug 11, 2026
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.

Source submenu closes when moving the mouse into it (openOnHover safePolygon)

1 participant