Skip to content

[navigation menu] Fix delayed trigger switches in Safari - #4310

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/navigation-menu-hover-perf
Mar 12, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/navigation-menu-hover-perf

Conversation

@atomiks

@atomiks atomiks commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This improves Navigation Menu hover performance during trigger-to-trigger switching.

What changed

  • Keep safePolygon pointer-events blocking enabled for non-WebKit browsers.
  • Disable top-level pointer-events blocking on WebKit, which avoids the Safari hover delay when switching triggers.
  • Keep nested Navigation Menu blocking behavior intact.
  • Reduce redundant size-sync work during trigger switches by skipping an extra auto-size pass when the trigger event already handled the size transition.
  • Add a regression test asserting top-level hover pointer-events mutations stay scoped to the list rather than document.body.

Why

Safari could intermittently delay hover activation when moving directly between top-level triggers. Entering the popup first consistently cleared the issue, which pointed to the top-level pointer-events mutation path rather than safePolygon geometry. Disabling that mutation on WebKit fixes the delay while preserving the better non-WebKit behavior.

@atomiks atomiks added performance component: navigation menu Changes related to the navigation menu component. labels Mar 12, 2026
@pkg-pr-new

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

commit: 804aeab

@atomiks

atomiks commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch narrows the Navigation Menu hover workaround to WebKit so Safari avoids the delayed trigger switch, while nested menus keep the existing scoped pointer-events behavior. It also keeps the trigger-switch size shortcut and adds WebKit-specific regression coverage for both top-level and nested menus.

Findings

No blocking issues found in this patch.

1. ℹ️ [Informational] Chromium timing stayed effectively flat

Impact: The change looks targeted to Safari/WebKit responsiveness rather than broad browser throughput, and the focused Chromium check did not show a wider performance regression.

Evidence: packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx:552 scopes the safe-polygon pointer-events path to nested menus on WebKit, while packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx:648 keeps the trigger-switch size shortcut. WebKit-specific regression coverage was added in packages/react/src/navigation-menu/root/NavigationMenuRoot.webkit.test.tsx:9. Focused Chromium benchmark using pnpm exec cross-env VITEST_ENV=chromium vitest run --project @base-ui/react src/navigation-menu/root/NavigationMenuRoot.test.tsx --no-watch:

Ref Commit Mean (ms) p50 (ms) p95 (ms) Sample size
upstream/master a3190b848 8603.67 8450.49 9035.86 3
PR head cbb4e010e 8633.01 8393.32 9068.31 3

Recommendation: None required. Keep a quick Safari manual check in normal release validation, because the user-facing win here is browser-specific and not expected to show up in Chromium timings.

Confidence: 4/5

High confidence based on a full-branch diff review, focused JSDOM and Chromium test runs, and a latest-master versus PR-head Chromium benchmark. Residual risk is low and mainly limited to Safari-specific pointer-events behavior outside the automated harness.

Notes

  • Latest revision squashes the branch into a single commit and uses isWebKit rather than a user-agent-specific Safari branch.
  • Focused verification run:
    • pnpm test:jsdom NavigationMenuRoot --no-watch
    • pnpm test:chromium NavigationMenuRoot --no-watch
    • pnpm prettier

@netlify

netlify Bot commented Mar 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

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

@mui-bot

mui-bot commented Mar 12, 2026 •

Copy link
Copy Markdown

Bundle size report

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

Details of bundle changes


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

@atomiks
atomiks force-pushed the codex/navigation-menu-hover-perf branch from d6b1c68 to cbb4e01 Compare March 12, 2026 08:44
@atomiks
atomiks marked this pull request as ready for review March 12, 2026 09:02
@atomiks atomiks changed the title [navigation menu] Improve hover performance [navigation menu] Fix delayed trigger switches in Safari Mar 12, 2026
@atomiks atomiks added type: bug It doesn't behave as expected. browser: Safari Affects or fixes behavior in Apple Safari. and removed performance labels Mar 12, 2026
@atomiks
atomiks merged commit 83743ba into mui:master Mar 12, 2026
9 checks passed
@atomiks
atomiks deleted the codex/navigation-menu-hover-perf branch March 12, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser: Safari Affects or fixes behavior in Apple Safari. 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