Skip to content

[menu] Optimize submenu hover pointer-events - #4231

Merged
atomiks merged 6 commits into
mui:masterfrom
atomiks:codex/submenu-hover-pointer-scope
Mar 5, 2026
Merged

atomiks merged 6 commits into
mui:masterfrom
atomiks:codex/submenu-hover-pointer-scope

Conversation

@atomiks

@atomiks atomiks commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

With big DOMs, this shows adding pointer-events: none; on the <body> is much slower than scoping it to the menu itself when quickly sweeping over submenu triggers. The conditional scope check will be removed before merge.

https://deploy-preview-4231--base-ui.netlify.app/experiments/menu/pointer-events-scope

Screen.Recording.2026-03-04.at.10.32.33.pm.mov

@atomiks atomiks added component: menu Changes related to the menu component. performance labels Mar 2, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 2, 2026 •

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

  • vite-css-base-ui-example

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

commit: 139f96d

@mui-bot

mui-bot commented Mar 2, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+77B(+0.02%) 🔺+14B(+0.01%)

Details of bundle changes


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

@netlify

netlify Bot commented Mar 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9d399e7
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69a8ee946f2ea900089bc23d
😎 Deploy Preview https://deploy-preview-4231--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.

@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Mar 2, 2026
@atomiks
atomiks force-pushed the codex/submenu-hover-pointer-scope branch from 660916a to 212069a Compare March 2, 2026 03:54
Comment on lines +131 to +133
let rootId = parent.store.select('rootId');
let floatingTreeRoot = parent.store.select('floatingTreeRoot');
let keyboardEventRelay = parent.store.select('keyboardEventRelay');

@atomiks atomiks Mar 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change to MenuStore specifically mainly improves submenus that have nested triggers:

scoped + items (flatter case)
TaskDuration median: 1.602s -> 1.574s (-1.8%)
ScriptDuration median: 0.324s -> 0.308s (-4.7%)

scoped + triggers (nested submenu-trigger stress case)
TaskDuration median: 2.857s -> 2.030s (-28.9%)
ScriptDuration median: 1.483s -> 0.734s (-50.5%)

@atomiks
atomiks marked this pull request as ready for review March 2, 2026 06:20
@atomiks

atomiks commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This PR changes hover submenus so pointer-event blocking stays local to the menu area instead of relying on a whole-page fallback, and it reduces unnecessary submenu updates from parent changes. The latest update removes the body/scoped toggle and keeps scoped behavior on all the time.

Findings

No blocking issues found in this patch.

1. ℹ️ [Informational] Focused Chromium timing is mostly close, with one noisy outlier on head

Impact: The updated scoped-only path does not show a clear functional regression, but the timing samples are noisy and include one slower run on head.

Evidence: Command used for both refs: pnpm test:chromium MenuSubmenuTrigger --no-watch (5 runs each on latest master and PR HEAD).

Ref Mean (ms) p50 (ms) p95 (ms) Sample size
master (7db989f31) 1727 1663 2078 5
HEAD (c5a7f46bd) 2047 1754 3261 5

Recommendation: Keep an eye on this in CI perf runs; if the outlier pattern repeats, capture a larger sample size on the submenu-hover path before drawing conclusions.

Confidence: 4/5

High confidence from a full PR pass, focused jsdom/chromium tests on touched menu paths, and fresh head-vs-master timing checks.

Notes

  • The scoped cleanup behavior remains covered by the MenuRoot regression test.
  • The experiment now reflects only scoped mode, matching the runtime behavior.

@atomiks
atomiks force-pushed the codex/submenu-hover-pointer-scope branch from c5a7f46 to 00623e0 Compare March 4, 2026 11:45
@atomiks
atomiks merged commit 0824de0 into mui:master Mar 5, 2026
6 checks passed
@atomiks
atomiks deleted the codex/submenu-hover-pointer-scope branch March 5, 2026 02:54
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. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants