fix(NavigationMenu): keyboard navigation in vertical orientation#6605
fix(NavigationMenu): keyboard navigation in vertical orientation#6605itsmelouis wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 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 |
commit: |
🔗 Linked issue
❓ Type of change
📚 Description
Keyboard navigation is broken in
verticalorientation as soon as an item haschildren.The reason: the trailing chevron of those items is rendered as
<AccordionTrigger as="span">. A<span>is not focusable, but it still gets reka'sdata-reka-collection-item, and the Accordion uses that attribute for its arrow-key (roving) navigation. So when you press Arrow Up/Down, focus tries to move to that span, can't (it's not focusable), and stays stuck there, you can't reach the next item. A link with children also can't be expanded/collapsed with the keyboard at all (the only toggle is that unreachable span).I fixed it the same way
ContentNavigationalready does it: invertical, items withchildrenare now rendered as a real focusableAccordionTrigger(<button>), and the chevron is just a decorative icon inside it. No more phantom non-focusable trigger → arrow keys work again and the section can be toggled with the keyboard.One small behavior change: a link that also has
childreninverticalnow toggles the accordion instead of navigating, which matcheshorizontalandContentNavigation.type: 'trigger'is no longer required for that (I kept it for backward compat).I added a regression test that checks every arrow-key target in
verticalis a focusablea/button.📝 Checklist