Skip to content

[navigation menu] Fix initial trigger switch size snap - #4327

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/navigation-menu-trigger-size-snap
Mar 19, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/navigation-menu-trigger-size-snap

Conversation

@atomiks

@atomiks atomiks commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

This is semi-hard to spot as it requires switching to a new trigger right as the popup's initial open animation is about to finish.

Summary

Prevents NavigationMenu from snapping to the next panel size when switching triggers right as the initial open animation finishes. The pending size reset from the first open is now canceled before a new trigger-switch resize transition starts.

Changes

  • Abort pending popup auto-size resets before starting another size transition.
  • Add a regression test covering the first trigger switch immediately after the initial open animation.

@atomiks atomiks added type: bug It doesn't behave as expected. component: navigation menu Changes related to the navigation menu component. labels Mar 13, 2026
@mui-bot

mui-bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+255B(+0.06%) 🔺+119B(+0.08%)

Details of bundle changes


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

@atomiks
atomiks force-pushed the codex/navigation-menu-trigger-size-snap branch from 0380425 to 0095a33 Compare March 13, 2026 07:03
@netlify

netlify Bot commented Mar 13, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

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

@pkg-pr-new

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

commit: ebe0a54

@netlify

netlify Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit ebe0a54
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bb574f4eb29a0008cfef0b
😎 Deploy Preview https://deploy-preview-4327--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 commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch fixes the first trigger-switch size snap by moving pending popup size-reset ownership up to the navigation menu root, so a stale animation callback from the previous trigger cannot win. It also adds a stronger regression test that keeps overlapping animations visible and wraps the async completion path in act(...).

Findings

No blocking issues found in this patch.

1. 🟡 [Non-blocking] Regression coverage still misses the reported hover path

Impact: The new test protects the shared reset logic in general, but it does not exercise the exact interaction path from the original bug report. A future regression that only affects hover timing could slip through while this test still passes.

Evidence: The user-facing report was about hovering between triggers, but the regression test opens and switches with fireEvent.click(...) in packages/react/src/navigation-menu/root/NavigationMenuRoot.test.tsx:2476-2485. In packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx:503-540, hover and click do not take the same state-transition path: hover sets isHover, runs changeState inside ReactDOM.flushSync(...), and also updates the patient-click bookkeeping before calling setValue(...).

Recommendation: Add a hover-driven version of this regression, or switch the current test to deterministic hover events, so the test covers the exact timing path that originally reproduced the snap.

Confidence: 4/5

High confidence based on a full-branch review across correctness, rendering/effect timing, accessibility/semantics, API/state design, maintainability/simplification, performance risk, and test quality. The latest CI on the current PR head also shows the relevant browser, lint, and regression jobs green; the main remaining risk is the hover-specific coverage gap above.

Notes

  • I used subagents for the category sweeps on React/rendering, API/state design, maintainability, performance, and test quality, then consolidated those results into this branch-wide review.
  • I did not find a credible runtime performance regression here, so I did not recommend a benchmark for this patch.

@atomiks
atomiks force-pushed the codex/navigation-menu-trigger-size-snap branch 7 times, most recently from 2b75e51 to f67e701 Compare March 16, 2026 08:30
@atomiks
atomiks marked this pull request as ready for review March 16, 2026 08:42
@atomiks
atomiks force-pushed the codex/navigation-menu-trigger-size-snap branch from ed87b51 to 153f162 Compare March 17, 2026 12:18
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 19, 2026
atomiks added 2 commits March 19, 2026 12:53
…menu-trigger-size-snap

# Conflicts:
#	packages/react/src/navigation-menu/root/NavigationMenuRootContext.ts
…ze-snap' into codex/navigation-menu-trigger-size-snap
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 19, 2026
@atomiks
atomiks merged commit 3fbd233 into mui:master Mar 19, 2026
7 checks passed
@atomiks
atomiks deleted the codex/navigation-menu-trigger-size-snap branch March 19, 2026 02:01
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