Bug: source submenu closes when moving the mouse into it
Version: @react-trace/kit 0.0.8 (reproduced with @react-trace/core 0.0.8, @base-ui/react ^1.2.0)
Summary
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 is moved into it — even while the pointer is still inside the popup. Clicking entries can also feel flaky ("buttons sometimes unclickable") because the menu closes before the click lands.
Steps to reproduce
- Start any Vite + React app with
<Trace root={...} /> mounted
- Activate the inspector, click an element to open the action panel
- Hover over any source entry in the panel (the ones with the chevron) — the submenu pops out
- Move the mouse toward/into the submenu — it closes while the pointer is still inside the popup's bounding box
Root cause (traced)
The Submenu in @react-trace/core uses DropdownMenu.Root with openOnHover: true, delay: 0, closeDelay: 0 (hardcoded). Closing is governed by floating-ui's safePolygon hover-intent, which only keeps the popup open if the pointer travels through a narrow safe zone between the trigger and the popup:
- The submenu is 482px wide vs the ~315px trigger entry, and when the viewport lacks room on the right it flips to the left of the trigger (
side: "right" with collisionPadding: 8). The polygon/trough math then doesn't match the path the mouse actually takes, and the popup closes even though contains(floating, target) would be true once the pointer is over the popup.
safePolygon also closes when the cursor is classified as "moving slowly" (CURSOR_SPEED_THRESHOLD 0.1 px/ms) and re-checks via a 40ms timeout — both timing-dependent, which matches reports that the popup sometimes survives and sometimes vanishes.
- With
closeDelay: 0, any missed "landing" closes the menu immediately, so the action buttons inside the popup can disappear between mousedown and mouseup.
Expected behavior
The submenu should stay open while the pointer is over the popup (standard hover-menu behavior), like other openOnHover menus.
Suggested fix
- Use a nonzero
closeDelay (e.g. 100–150ms) on the submenu trigger, and/or
- Ensure the popup registers as "landed" when the pointer enters it regardless of flip side (the
side: "right" flip to left combined with the wide popup seems to be what breaks safePolygon's assumptions).
Reproduction
Automated repro (Playwright, headless, against a dev server): hover a source entry, then move the mouse in 7px steps toward the popup — logs show menus: 1 until the pointer is ~3px inside the popup's edge, then menus: 0:
step 23: (849,572.75) menus: 1
step 24: (842,572.75) menus: 1 <- pointer inside popup rect (363..845)
step 25: (835,572.75) menus: 0 <- popup removed while pointer inside it
Bug: source submenu closes when moving the mouse into it
Version: @react-trace/kit 0.0.8 (reproduced with @react-trace/core 0.0.8, @base-ui/react ^1.2.0)
Summary
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 is moved into it — even while the pointer is still inside the popup. Clicking entries can also feel flaky ("buttons sometimes unclickable") because the menu closes before the click lands.
Steps to reproduce
<Trace root={...} />mountedRoot cause (traced)
The
Submenuin@react-trace/coreusesDropdownMenu.RootwithopenOnHover: true, delay: 0, closeDelay: 0(hardcoded). Closing is governed by floating-ui'ssafePolygonhover-intent, which only keeps the popup open if the pointer travels through a narrow safe zone between the trigger and the popup:side: "right"withcollisionPadding: 8). The polygon/trough math then doesn't match the path the mouse actually takes, and the popup closes even thoughcontains(floating, target)would be true once the pointer is over the popup.safePolygonalso closes when the cursor is classified as "moving slowly" (CURSOR_SPEED_THRESHOLD0.1 px/ms) and re-checks via a 40ms timeout — both timing-dependent, which matches reports that the popup sometimes survives and sometimes vanishes.closeDelay: 0, any missed "landing" closes the menu immediately, so the action buttons inside the popup can disappear between mousedown and mouseup.Expected behavior
The submenu should stay open while the pointer is over the popup (standard hover-menu behavior), like other
openOnHovermenus.Suggested fix
closeDelay(e.g. 100–150ms) on the submenu trigger, and/orside: "right"flip toleftcombined with the wide popup seems to be what breakssafePolygon's assumptions).Reproduction
Automated repro (Playwright, headless, against a dev server): hover a source entry, then move the mouse in 7px steps toward the popup — logs show
menus: 1until the pointer is ~3px inside the popup's edge, thenmenus: 0: