fix(NavigationMenu): ignore inactive content dismiss#2637
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR guards NavigationMenuContentImpl.handleDismiss so it only dismisses when the component's item matches the menu's current modelValue, and adds a test fixture plus test to validate behavior when ChangesNavigationMenu Dismiss Guard and Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/NavigationMenu/NavigationMenu.test.ts`:
- Around line 106-122: The test "keeps active content open when clicking inside
with unmountOnHide disabled" (using NavigationMenuUnmountOnHideFalse) only opens
one content and thus misses the multi-content dismiss-handler bug; update the
spec to open two contents so inactive-but-mounted content exists: trigger click
on '[data-testid="trigger-one"]', then open the second content via
'[data-testid="trigger-two"]' (ensuring unmountOnHide=false keeps the first
mounted), then fire a pointerDown inside the active content element
'[data-testid="inside-two"]' and assert '[data-testid="model-value"]' remains
'two'; this verifies inactive content's dismiss handler does not close the
active content.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 46fdd5e4-62f0-41f6-aecb-1fe440cbe855
📒 Files selected for processing (3)
packages/core/src/NavigationMenu/NavigationMenu.test.tspackages/core/src/NavigationMenu/NavigationMenuContentImpl.vuepackages/core/src/NavigationMenu/__test__/NavigationMenuUnmountOnHideFalse.vue
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
🔗 Linked issue
Closes #2608
❓ Type of change
📚 Description
This fixes an issue where
NavigationMenucan dismiss the currently active content incorrectly whenunmountOnHideis set tofalse.With
unmountOnHide={false}, multipleNavigationMenuContentinstances can remain mounted at the same time. An inactive content’sDismissableLayercan still dispatch a dismiss event, which causes the root menu state to clear even though the event did not come from the active item.This PR updates the dismiss handler so inactive
NavigationMenuContentinstances ignore dismiss events. Only the currently active item is allowed to trigger the root dismiss behavior.It also adds a regression fixture and test covering the multiple-mounted-content case.
📸 Screenshots (if appropriate)
N/A — behavior-only bug fix covered by regression test.
📝 Checklist
Summary by CodeRabbit
Bug Fixes
Tests