Skip to content

Menu: Fix pointer transfer to collision-flipped submenus - #4037

Open
wanxiankai wants to merge 1 commit into
radix-ui:mainfrom
wanxiankai:fix/flipped-submenu-pointer-transfer
Open

Menu: Fix pointer transfer to collision-flipped submenus#4037
wanxiankai wants to merge 1 commit into
radix-ui:mainfrom
wanxiankai:fix/flipped-submenu-pointer-transfer

Conversation

@wanxiankai

Copy link
Copy Markdown

Description

Closes #4036

When a submenu collision-flips, a coalesced pointer move can reach the submenu before another pointermove updates pointerDirRef. The stale direction makes the grace-area check fail and moves focus back to the parent menu, allowing React 19 to unmount the submenu before the queued click lands.

This change derives the direction from the latest pointerleave coordinate when it differs from the last recorded pointer position. Pointer-move and item-entry behavior continue using the existing recorded direction, preserving the current grace-area behavior.

A Playwright regression test uses the existing narrow-viewport nested submenu, verifies that it collision-flipped to the left, and clicks its item with a single pointer move.

Testing

  • pnpm format:check
  • pnpm lint
  • pnpm test --run (37 files, 464 passed, 2 skipped)
  • pnpm types:check
  • pnpm build (62 packages)
  • pnpm exec playwright test e2e/dropdown-menu.spec.ts --project=chromium (17 passed)

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b3fadf0

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

This PR includes changesets to release 5 packages
Name Type
@radix-ui/react-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-menubar Patch
radix-ui 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

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.

[DropdownMenu] Collision-flipped submenu closes before a click can land under React 19 (grace-intent direction is stale for the flipped side)

2 participants