Skip to content

[navigation-menu] Fix frozen menu when the open trigger unmounts - #5240

Merged
atomiks merged 4 commits into
mui:masterfrom
DreierF:fix/navigation-menu-frozen-pointer-events
Jul 16, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
DreierF:fix/navigation-menu-frozen-pointer-events

Conversation

@DreierF

@DreierF DreierF commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #5239

The contributing guide does not have a PR section 🤔

@pkg-pr-new

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

commit: 467fa33

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+6B(0.00%) 🔺+6B(0.00%)

Details of bundle changes


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

@netlify

netlify Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 467fa33
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a587f4f52db93000806ef8e
😎 Deploy Preview https://deploy-preview-5240--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 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

PR review

No correctness blockers. The component-scoped unmount cleanup addresses the stale list lock and is ownership-safe; the only suggestion is an optional consolidation with the existing hover-state effect. The PR’s Chromium regression passed, and the consolidated form also passed the full Navigation Menu suites in Chromium and jsdom.

Bugs (0)

No findings.

Tests (0)

No findings.

Simplifications (1)

1. ℹ️ Fold the unmount cleanup into the existing hover-state effect

Location: packages/react/src/navigation-menu/trigger/NavigationMenuTrigger.tsx:582

React.useEffect(() => {
  return () => {
    clearSafePolygonPointerEventsMutation(hoverInteractionState);
  };
}, [hoverInteractionState]);

The standalone effect is correct, but the effect immediately above already owns the closed-state reset for the same hoverInteractionState. It can return this cleanup instead. The existing call inside if (!open) can then be removed: when open changes from true to false, React runs the preceding effect cleanup first, and unmounting runs the same cleanup.

The consolidated form passed all Navigation Menu tests: 286 passed and 17 skipped in Chromium; 278 passed and 25 skipped in jsdom.

Failure scenario: There is no user-visible failure in the current patch; the separate effect adds unnecessary hook work and production code for lifecycle handling that can share one effect.

Fix: Return clearSafePolygonPointerEventsMutation(hoverInteractionState) from the existing [context, hoverInteractionState, open] effect and remove both the standalone effect and the closed-state call.

Do not move this into HoverInteraction.dispose(): the shared interaction can have multiple hook consumers, so one consumer unmounting could clear a lock another still needs. NavigationMenuTrigger is the correct scope.

Docs (0)

No findings.

Verdict

Approve - the lifecycle fix is correct; consolidating the effect is optional.


🤖 Review generated with Codex

@DreierF

DreierF commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Applied the simplification

@atomiks atomiks added type: bug It doesn't behave as expected. component: navigation menu Changes related to the navigation menu component. labels Jul 16, 2026

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @DreierF

@atomiks
atomiks merged commit 3089301 into mui:master Jul 16, 2026
6 checks passed
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.

[navigation menu] NavigationMenu can permanently freeze

2 participants