Skip to content

[menu] Fix submenu trigger interactions - #4892

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/menu-runtime-bugs
May 25, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/menu-runtime-bugs

Conversation

@atomiks

@atomiks atomiks commented May 22, 2026

Copy link
Copy Markdown
Contributor

This is part of the Codex component behavior and test coverage sweep. It fixes Menu behavior bugs found during review and adds focused test coverage for the affected paths.

Changes

  • Register Menu.SubmenuTrigger labels for typeahead.
  • Respect highlightItemOnHover={false} for submenu triggers.
  • Stop controlled-open disabled menus from accepting typeahead, item clicks, and submenu trigger interaction.
  • Run Menu.SubmenuTrigger conformance against the actual submenu trigger element.
  • Add coverage for submenu trigger typeahead, hover highlighting, disabled controlled-open menus, and conformance.

Original findings addressed

  • [P2] Menu.SubmenuTrigger ignores its label prop for typeahead.
  • [P2] highlightItemOnHover={false} is bypassed for submenu triggers.
  • [P2] Controlled-open disabled menus still accept item/typeahead interaction.
  • [P2] Menu.SubmenuTrigger conformance is effectively untested.

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

pkg-pr-new Bot commented May 22, 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@4892
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4892
    

commit: 509b27b

@code-infra-dashboard

code-infra-dashboard Bot commented May 22, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+210B(+0.05%) 🔺+36B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,301.42 ms -104.33 ms(-7.4%) | Renders: 50 (+0) | Paint: 2,000.08 ms -153.60 ms(-7.1%)

Test Duration Renders
Checkbox mount (500 instances) 86.71 ms 🔺+16.72 ms(+23.9%) 1 (+0)
Select mount (200 instances) 133.73 ms ▼-54.60 ms(-29.0%) 3 (+0)
Menu mount (300 instances) 136.97 ms ▼-39.36 ms(-22.3%) 2 (+0)
Mixed surface mount (app-like density) 71.00 ms ▼-25.97 ms(-26.8%) 5 (+0)
Select open (500 options) 45.85 ms ▼-16.44 ms(-26.4%) 14 (+0)

7 tests within noise — details


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

@atomiks
atomiks force-pushed the codex/menu-runtime-bugs branch from 5a7e3b2 to e4b0b8e Compare May 22, 2026 11:56
@netlify

netlify Bot commented May 22, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5a7e3b2
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a1042fe9b1d800008de36c3
😎 Deploy Preview https://deploy-preview-4892--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@netlify

netlify Bot commented May 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 509b27b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a143f57a2e3d70008b538de
😎 Deploy Preview https://deploy-preview-4892--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@atomiks
atomiks marked this pull request as ready for review May 22, 2026 12:26
@atomiks

atomiks commented May 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Code Review (GPT-5.5 + Opus 4.7)

Approve after nits are addressed 🟡 The refreshed full diff against upstream/master fixes the menu interaction regressions at the right layers and the affected jsdom/Chromium suites pass; only a small test-name cleanup remains.

Opus 4.7 supplied the static-review notes synthesized here; GPT-5.5 refreshed the diff and ran the validation suites before posting.

1. Bugs / Issues

1. ℹ️ Clarify the hover regression test name (informational)

packages/react/src/menu/root/MenuRoot.test.tsx

it('does not highlight submenu triggers from mouse enter when disabled', async () => {
  await render(
    <TestMenuContents
      rootProps={{ open: true, highlightItemOnHover: false }}

This test is in the highlightItemOnHover block and exercises highlightItemOnHover={false}, not the disabled prop. The assertion is correct, but the name points future readers at the wrong behavior.

Recommendation: Rename the test to mention highlightItemOnHover={false} rather than disabled.

Root Cause & Patch Assessment

The fixes line up with the actual failure points:

  • Menu.SubmenuTrigger now passes label into useCompositeListItem({ label }), which lets typeahead use the explicit label while preserving the existing text-content fallback when label is undefined.
  • highlightItemOnHover={false} is now synced into the menu store and checked by the submenu trigger's extra onMouseEnter -> setActive() path, closing the gap that regular items already avoided through useListNavigation({ focusItemOnHover }).
  • Controlled-open disabled menus are made inert across the relevant interaction paths: typeahead is gated with enabled: !disabled, regular items inherit store.disabled through useMenuItem, and submenu triggers also include the parent menu's disabled state.
  • The conformance test now renders Menu.SubmenuTrigger itself and expects the correct HTMLDivElement shape instead of accidentally testing Menu.Trigger.

Pattern Consistency Assessment

The root-disabled behavior follows the existing menu model: MenuStore already centralizes root and menubar-disabled state, and the PR extends that state to item activation instead of only trigger/open behavior. Reading highlightItemOnHover with select() inside the event handler is also the right shape because it needs the latest store value at event time without adding another reactive subscription.

Test Coverage Assessment

The added coverage maps directly to the fixed regressions: submenu trigger typeahead labels, hover highlighting opt-out, disabled controlled-open item/typeahead behavior, disabled submenu triggers, and real submenu trigger conformance.

Validated with:

pnpm test:jsdom MenuSubmenuTrigger --no-watch
pnpm test:jsdom MenuRoot --no-watch
pnpm test:chromium MenuSubmenuTrigger --no-watch
pnpm test:chromium MenuRoot --no-watch

@atomiks
atomiks merged commit 738b417 into mui:master May 25, 2026
6 checks passed
@atomiks
atomiks deleted the codex/menu-runtime-bugs branch May 25, 2026 12:36
mbrookes pushed a commit to mbrookes/base-ui that referenced this pull request May 25, 2026
@twillhorn twillhorn mentioned this pull request Jul 7, 2026
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.

1 participant