[navigation-menu] Close parent menus when nested link with closeOnClick is clicked#4276
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ge-fix # Conflicts: # packages/react/src/navigation-menu/root/NavigationMenuRoot.test.tsx
Codex ReviewOverviewThis patch makes Findings (None)No blocking issues found in this patch. Confidence: 4/5High confidence based on a full pass over Notes
|
Closes #4262
Previously, when a nested link with
closeOnClickwas clicked, only the nearestNavigationMenu.Rootclosed and the parent menu stayed open. We now bubble that close up so the whole menu closes without needing to control the root withvalue/onValueChange.Changes
useNavigationMenuRootContext(true). InsetValue, after updating local state, if we're closing witheventDetails.reason === REASONS.linkPress, we callparentRootContext.setValue(null, eventDetails)so the parent (and its ancestors) close as well.onValueChange, one with three nested levels and three tests under "nested menus": parent closes when nested link is clicked, parentonValueChangeis called withnull, and all three levels close when the deepest link is clicked.