Skip to content

[menu] Fix closeDelay not applied on Menu.SubmenuTrigger - #4134

Merged
flaviendelangle merged 5 commits into
mui:masterfrom
flaviendelangle:closeDelay-subMenuTrigger
Mar 10, 2026
Merged

flaviendelangle merged 5 commits into
mui:masterfrom
flaviendelangle:closeDelay-subMenuTrigger

Conversation

@flaviendelangle

@flaviendelangle flaviendelangle commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

@flaviendelangle flaviendelangle self-assigned this Feb 18, 2026
@flaviendelangle flaviendelangle added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. labels Feb 18, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 18, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4134
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4134
    

commit: e96ced3

@netlify

netlify Bot commented Feb 18, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0247007
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6995bffd863fc5000849b44f
😎 Deploy Preview https://deploy-preview-4134--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot

mui-bot commented Feb 18, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+174B(+0.04%) 🔺+81B(+0.05%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Feb 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9e19fe5
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69afc83e70048400081a53bc
😎 Deploy Preview https://deploy-preview-4134--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@flaviendelangle
flaviendelangle marked this pull request as ready for review February 18, 2026 13:46
@flaviendelangle flaviendelangle changed the title [menu] Fix closeDelay not applied on Menu.SubmenuTrigger [menu] Fix closeDelay not applied on Menu.SubmenuTrigger Feb 18, 2026
@michaldudak

michaldudak commented Mar 5, 2026 •

Copy link
Copy Markdown
Member

Codex Review

Overview

This PR applies Menu.SubmenuTrigger closeDelay when a sibling item is hovered, and adds coverage for that hover-close path. The change addresses a real timing gap for nested menus opened by hover.

Findings

1. 🟡 [Non-blocking] closeDelay restarts on every sibling mousemove

Impact: The submenu close can be postponed beyond the configured closeDelay whenever the pointer keeps moving over sibling items, so the close timing behaves like "close after pointer rests" rather than "close after sibling hover begins".

Evidence: useMenuItemCommonProps emits itemhover on every onMouseMove (packages/react/src/menu/item/useMenuItemCommonProps.ts:58-68), and MenuPositioner restarts the timer on each emitted event (packages/react/src/menu/positioner/MenuPositioner.tsx:195-200). The new test covers a single mouseMove event only (packages/react/src/menu/root/MenuRoot.test.tsx:1359-1369), so repeated-move behavior is not asserted.

Performance check for this hot-path change (focused Chromium test, PR head vs latest master):

Ref Mean (s) p50 (s) p95 (s) n
upstream/master (a42221c8f) 3.01 2.90 3.49 5
PR head (4f59c4d6e) 3.09 2.90 3.91 5

Recommendation: Start the delayed close once per sibling transition instead of restarting it on every move (for example, gate start() with !closeTimeout.isStarted() or track last hovered target). Add a test that dispatches multiple mouseMove events over the sibling item before the delay elapses.

2. ℹ️ [Informational] Close-delay behavior is now split across two timing implementations

Impact: Manual timeout orchestration in MenuPositioner adds another close-delay implementation next to existing hover-delay handling, increasing the chance of future semantic drift.

Evidence: MenuPopup uses useHoverFloatingInteraction(..., { closeDelay }), while sibling-hover close now uses custom start/clear logic in MenuPositioner.

Recommendation: Consider extracting a small shared helper for delayed-close scheduling/cancellation (or at minimum document the intentional semantic differences) so future updates keep close-delay behavior aligned.

No blocking issues found in this patch.

Confidence: 4/5

High confidence from full master...head diff inspection plus targeted JSDOM/Chromium validation and a focused head-vs-master benchmark; moderate residual risk remains around repeated mousemove semantics.

Notes

  • Verification run included pnpm test:jsdom MenuRoot --no-watch and focused Chromium checks for the affected scenario.

@flaviendelangle

Copy link
Copy Markdown
Member Author

@michaldudak review applied 👍

@michaldudak michaldudak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!

@flaviendelangle
flaviendelangle merged commit 1d13fe2 into mui:master Mar 10, 2026
6 checks passed
@flaviendelangle
flaviendelangle deleted the closeDelay-subMenuTrigger branch March 10, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: menu Changes related to the menu component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[menu] [submenutrigger] closeDelay not working on SubmenuTrigger

3 participants