Skip to content

[menu] Fix focus not returning to trigger on <kbd>Esc</kbd> while pointer rests on popup - #3482

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:fix/hover-focus-return
Dec 10, 2025
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:fix/hover-focus-return

Conversation

@atomiks

@atomiks atomiks commented Dec 9, 2025 •

Copy link
Copy Markdown
Contributor

The mouseleave onScrollMouseLeave handler fires after pressing Esc due to it closing with pointer-events: none. This ends up causing the FloatingFocusManager to write to preventReturnFocusRef since the trigger-hover reason gets emitted after the escape-key reason, which blocks focus returning to the trigger.

The fix here is to check the open state (store.select('open')) before running the handler logic so it doesn't try to fire a new event.

NB: regression test doesn't work without animations on the popup (this issue doesn't occur there) and would likely be flaky if it was attempted to be added

@atomiks atomiks added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. labels Dec 9, 2025
@pkg-pr-new

pkg-pr-new Bot commented Dec 9, 2025 •

Copy link
Copy Markdown
  • vite-css-base-ui-example

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

commit: 1cabe9f

@mui-bot

mui-bot commented Dec 9, 2025 •

Copy link
Copy Markdown

Bundle size report

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

Details of bundle changes


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

@netlify

netlify Bot commented Dec 9, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 1cabe9f
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/693976e89c8583000818aac7
😎 Deploy Preview https://deploy-preview-3482--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 December 9, 2025 22:28
@LukasTy LukasTy changed the title [menu] Fix focus not returning to trigger on <kbd>Esc<kbd> while pointer rests on popup [menu] Fix focus not returning to trigger on <kbd>Esc</kbd> while pointer rests on popup Dec 10, 2025
@atomiks
atomiks force-pushed the fix/hover-focus-return branch from 54a513c to d221083 Compare December 10, 2025 12:29

@LukasTy LukasTy 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.

Nice and clean fix. 👍

@atomiks
atomiks merged commit 106d3f6 into mui:master Dec 10, 2025
22 checks passed
@atomiks
atomiks deleted the fix/hover-focus-return branch December 10, 2025 13: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.

3 participants