Skip to content

[navigation menu] Fix interaction, value, and styling-hook bugs - #4942

Merged
atomiks merged 13 commits into
mui:masterfrom
atomiks:codex/navigation-menu-sweep
Jun 3, 2026
Merged

atomiks merged 13 commits into
mui:masterfrom
atomiks:codex/navigation-menu-sweep

Conversation

@atomiks

@atomiks atomiks commented May 29, 2026

Copy link
Copy Markdown
Contributor

This is part of the Codex sweep for Navigation Menu. It restores the local fixes from the recovered branch while preserving newer upstream changes.

Changes

  • Prevented disabled triggers from opening through hover, click, or keyboard paths.
  • Avoided duplicate onValueChange calls when switching items via keyboard.
  • Treated non-nullish falsy item values as valid open values.
  • Exposed the documented actionsRef.unmount() action.
  • Pinned left-side popup transitions to the correct edge.
  • Documented the missing Navigation Menu styling hooks.

Original findings addressed

  • Disabled triggers could still activate their content.
  • Keyboard activation could emit duplicate value changes.
  • Falsy item values were handled like closed values in root cleanup.
  • The documented imperative unmount action was not wired up.
  • Popup and data-attribute styling hooks were incomplete.

@atomiks atomiks added component: navigation menu Changes related to the navigation menu component. type: bug It doesn't behave as expected. labels May 29, 2026 — with ChatGPT Codex Connector
@pkg-pr-new

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

commit: 0d2db2c

@code-infra-dashboard

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

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+204B(+0.04%) 🔺+78B(+0.05%)

Details of bundle changes

Performance

Total duration: 1,218.24 ms -48.64 ms(-3.8%) | Renders: 50 (+0) | Paint: 1,847.66 ms -62.11 ms(-3.3%)

No significant changes — details


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

@netlify

netlify Bot commented May 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0d2db2c
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a209b1984b0cb0008467292
😎 Deploy Preview https://deploy-preview-4942--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 force-pushed the codex/navigation-menu-sweep branch 2 times, most recently from 7f8bb7f to 3ae7143 Compare June 1, 2026 23:03
@atomiks
atomiks marked this pull request as ready for review June 1, 2026 23:04

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

PR Review Summary — #4942 [navigation menu] Fix interaction, value, and styling-hook bugs

Branch: codex/navigation-menu-sweep (5 nav-menu commits, 12 files, +324/−28)
Reviewers: code-reviewer · pr-test-analyzer · silent-failure-hunter · comment-analyzer
Verdict: Fixes are sound; the gaps are almost entirely in test coverage.

Critical Issues (0 found)

None. The four claimed fixes (disabled-trigger guards, onValueChange dedup, falsy item values, actionsRef.unmount()) all hold up under inspection, and no silent failures, swallowed errors, or improper fallbacks were introduced.

Important Issues (5 found — all in test coverage)

  1. Disabled-trigger touch path uncovered — NavigationMenuRoot.test.tsx:1820-1866
    The source guard at NavigationMenuTrigger.tsx:700-702 covers all pointer types, but the suite only exercises mouse/keyboard. Add a pointerDown/pointerUp with pointerType: 'touch' (pattern at :1188-1262).

  2. Falsy value coverage incomplete — NavigationMenuRoot.test.tsx:1587-1618, 2637-2656
    Only value={0} is tested, but the predicate change at NavigationMenuRoot.tsx:157,169,178 applies equally to '' and false. Parametrize with all three (it.each).

  3. Duplicate onValueChange test doesn't faithfully traverse — NavigationMenuRoot.test.tsx:1561-1585
    The test programmatically focuses trigger2 before pressing ArrowDown, so the listNavigation traversal path the guard at NavigationMenuTrigger.tsx:663 actually targets isn't exercised. Use real ArrowRight/ArrowLeft across triggers with the popup open.

  4. actionsRef.unmount() not exercised mid-transition or while open — NavigationMenuRoot.test.tsx:1868-1894
    The test only calls unmount() after a clean close. The very scenario that justifies the API — unmount while open or mid-animation — isn't covered.

  5. side="left" test is layout-dependent in jsdom — NavigationMenuRoot.test.tsx:1896-1925
    Without real bounding rects, useAnchorPositioning may resolve to its default side, silently passing the negative case. Either wrap with describe.skipIf(isJSDOM) or assert via data-side="left". RTL inline-start/inline-end branch at NavigationMenuPopup.tsx:49-53 is also entirely untested.

Suggestions (6 found)

  1. Hover test uses fireEvent.mouseEnter instead of pointerEnter — NavigationMenuRoot.test.tsx:1821-1834
    useHoverFloatingInteraction requires pointerEnter with pointerType: 'mouse' (pattern at :1192,1222). Current test likely passes only because disabled short-circuits interactionsEnabled, not because the hover code path runs.

  2. "Suppress initial open transitions" undertested — NavigationMenuRoot.test.tsx:1507-1540
    Asserts transition: 'none' immediately after click but never asserts it's cleared on a subsequent tick. A regression that pins instant: true forever would pass.

  3. Nested falsy setValue(null) propagation untested — NavigationMenuRoot.tsx:177-184
    New nested branch using nextValue == null has no regression test.

  4. Positioner resize-listener re-subscription is fragile — NavigationMenuPositioner.tsx:139-162
    Adding instant to deps causes the resize listener to unsubscribe/re-subscribe on every flip. Works only because handleResize does flushSync(setInstant(true)) before instantTimeout.start(100, …). Either add a comment explaining the ordering invariant, or split the effects.

  5. Three comment-clarity nits

    • NavigationMenuRoot.tsx:214 — useImperativeHandle for actionsRef is silent about the contract that consumer opt-in disables auto-unmount via enabled: !actionsRef on both useOpenChangeComplete calls. One line of "why" warranted.
    • NavigationMenuTrigger.tsx:661-663 — comment cites onKeyDown but the guard sits inside handleActivation; clarify.
    • NavigationMenuList.tsx:99-101 — comment about "skipping the onKeyDown handler" describes work done earlier at line 72, not here.
  6. Public docs likely need regeneration — docs/src/app/(docs)/react/components/page.mdx:1102
    The Trigger prop list does not include disabled. This PR is the first that makes disabled materially observable on the Trigger. Run pnpm docs:api to regenerate.

Strengths

  • All four claimed fixes verified correct; nextValue == null replaces !nextValue consistently in every site (Root lines 157, 169, 178), and the trigger-side guards (NavigationMenuList.tsx:44-46, NavigationMenuTrigger.tsx:130-132) mirror that.
  • Disabled-trigger guard is layered correctly: && !disabled on the interaction hooks, an early-return in handleOpenEvent, and useButton's own keyboard short-circuit one layer down.
  • actionsRef wiring is null-safe (no error swallowing in handleUnmount).
  • New data-attribute files (anchorHidden on Popup, popupOpen on Icon, typed activationDirection) are accurately wired and match types.md + page.mdx.
  • Tests use vi.fn() with call-count assertions, flushMicrotasks(), and await act(...) deterministically.
  • No window.setTimeout, requestAnimationFrame, raw document/window, or React.useLayoutEffect were introduced — AGENTS.md guidelines followed.

Recommended Action

  1. Tests are the only blocker. Add coverage for items 1–5 before merging — they're the meaningful regressions a future change could re-introduce undetected.
  2. Apply comment clarifications (item 10) and run pnpm docs:api (item 11) — both are mechanical.
  3. Address suggestions 6–9 opportunistically.

@atomiks
atomiks force-pushed the codex/navigation-menu-sweep branch from 3ae7143 to eaff629 Compare June 3, 2026 07:17
@atomiks
atomiks force-pushed the codex/navigation-menu-sweep branch from 8b1a9b2 to 0b15844 Compare June 3, 2026 07:35
@atomiks
atomiks force-pushed the codex/navigation-menu-sweep branch from 24cb3c2 to 0d2db2c Compare June 3, 2026 21:22
@atomiks
atomiks merged commit 657b5b5 into mui:master Jun 3, 2026
6 checks passed
@atomiks
atomiks deleted the codex/navigation-menu-sweep branch June 3, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: navigation menu Changes related to the navigation 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