Skip to content

Commit

Permalink
fix(NavigationMenu): subcontent keydown skipping item (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia authored Aug 12, 2024
1 parent 5d994ee commit 12af841
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ function handleEscapeKeyDown(ev: KeyboardEvent) {
}
function handleKeydown(ev: KeyboardEvent) {
// prevent parent menu triggering keydown event
if ((ev.target as HTMLElement).closest('[data-radix-navigation-menu]') !== menuContext.rootNavigationMenu.value)
return
const isMetaKey = ev.altKey || ev.ctrlKey || ev.metaKey
const isTabKey = ev.key === 'Tab' && !isMetaKey
const candidates = getTabbableCandidates(ev.currentTarget as HTMLElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ provideNavigationMenuContext({
:as-child="asChild"
:data-orientation="orientation"
:dir="dir"
data-radix-navigation-menu
>
<slot :model-value="modelValue" />
</Primitive>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ provideNavigationMenuContext({
:data-orientation="orientation"
:as-child="props.asChild"
:as="as"
data-radix-navigation-menu
>
<slot :model-value="modelValue" />
</Primitive>
Expand Down

0 comments on commit 12af841

Please sign in to comment.