Skip to content

[menubar] Reset stale focus blocking when focus interactions are disabled - #6178

Open
Linruoxin-Sy wants to merge 1 commit into
mui:masterfrom
Linruoxin-Sy:fix/menubar-focus-reset
Open

Linruoxin-Sy wants to merge 1 commit into
mui:masterfrom
Linruoxin-Sy:fix/menubar-focus-reset

Conversation

@Linruoxin-Sy

Copy link
Copy Markdown

After opening the File, Edit, and View menubar menus with the pointer and dismissing each with Escape, opening File with ArrowDown and pressing ArrowRight focuses the Edit trigger without opening its menu.

useFocus blocks focus-based reopening after Escape or a trigger press. When the interaction is disabled, its blur and mouseleave handlers are removed, so their cleanup cannot reset that block. The stale block can survive until focus opening is enabled again.

Reset both blockFocusRef and blockedReferenceRef in the disabled effect branch. The dismissal block remains in effect while the interaction stays enabled.

The change is limited to the shared focus hook and its tests. The tests cover reopening after a disabled period and retaining the Escape block without a disabled period. The new reopening test fails on the original source and passes with the two-line reset; the existing window-blur test also continues to pass.

Reproduction

An independent Vite/React reproduction uses the unmodified published @base-ui/react@1.9.0 package, with no CSS or component wrappers.

StackBlitz reproduction

  1. Click File, press Escape, then move the pointer outside the menubar without clicking.
  2. Repeat for Edit, then View.
  3. Keep the pointer outside. Press Home, then ArrowDown to focus File command.
  4. Press ArrowRight. The Edit trigger receives focus, but Edit command does not become visible.

Validation

  • Related Menu, Menubar, Tooltip, PreviewCard, and useFocus suites: 1715 passed / 473 skipped in JSDOM; 2144 passed / 44 skipped in Chromium. Existing skip guards were retained, including the JSDOM-only useFocus file; no new skip guard was introduced.
  • pnpm prettier, pnpm eslint, pnpm stylelint, and pnpm typescript passed.
  • pnpm --filter @base-ui/utils --filter @base-ui/react build passed.
  • The actual ESM and CommonJS build outputs passed the pointer/Escape/ArrowDown/ArrowRight sequence in Chromium and WebKit at 1280x844 and 390x844, four consecutive cycles per combination.

Browser limitation

The same sequence still fails in Firefox on Windows after the stale block is cleared: the newly focused trigger does not match :focus-visible, so the existing focus-visible check prevents opening. A diagnostic build bypassing only that check confirms the additional cause. This PR addresses the stale dismissal state; it does not change focus-visible handling or claim to fix that Firefox behavior.

@pkg-pr-new

pkg-pr-new Bot commented Nov 5, 2026

Copy link
Copy Markdown

commit: 15bcf67

@Linruoxin-Sy

Copy link
Copy Markdown
Author

what
why fail? I I succeeded in running all cis locally.

@zannager zannager added the component: menubar Changes related to the menubar component. label Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: menubar Changes related to the menubar component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants