Skip to content

[menu] Prevent pointerleave from stealing dialog focus#4125

Merged
atomiks merged 2 commits intomui:masterfrom
atomiks:codex/menu-alert-dialog-pointer-leave-focus
Mar 4, 2026
Merged

[menu] Prevent pointerleave from stealing dialog focus#4125
atomiks merged 2 commits intomui:masterfrom
atomiks:codex/menu-alert-dialog-pointer-leave-focus

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Feb 18, 2026

When clicking a menu item that's a dialog trigger with a pointer, focus would be taken from the dialog by onPointerLeave.

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

pkg-pr-new bot commented Feb 18, 2026

commit: d3d7c49

@mui-bot
Copy link

mui-bot commented Feb 18, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+48B(+0.01%) 🔺+21B(+0.01%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for base-ui ready!

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

@atomiks atomiks marked this pull request as ready for review February 18, 2026 04:31
@atomiks
Copy link
Contributor Author

atomiks commented Mar 4, 2026

Codex Review

Overview

This PR updates pointer-leave handling in list navigation so menu focus is only restored when focus is still inside the menu floating element, which prevents nested alert dialog focus from being stolen. It also adds a Chromium-only regression test covering a nested AlertDialog trigger inside Menu.

Findings (None)

No blocking issues found in this patch.

Confidence: 4/5

High confidence from a full branch-diff review (master...c750efaa), targeted unit coverage checks, and a focused hot-path perf spot-check.

Notes

  • Full branch scope reviewed (single commit branch).
  • Test evidence: pnpm test:jsdom MenuRoot --no-watch and pnpm test:chromium MenuRoot --no-watch both passed.
  • Perf spot-check method: Chromium micro-benchmark via @playwright/test comparing unconditional focus vs activeElement + contains + conditional focus over 5 runs × 100,000 iterations.
  • Perf spot-check result: mean overhead was 6.26ms per 100,000 iterations (0.063µs per event), which is negligible in practice.

@atomiks atomiks merged commit 205a9a0 into mui:master Mar 4, 2026
22 checks passed
@atomiks atomiks deleted the codex/menu-alert-dialog-pointer-leave-focus branch March 4, 2026 07:55
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.

2 participants