Skip to content

Commit

Permalink
fix(ui): fix keyboard navigation through popper items
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeynalliZeynal committed Jan 18, 2025
1 parent ac0f709 commit cae536f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions components/ui/primitives/popper/popper-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,21 @@ export function PopperContent(props: PopperContentProps) {
switch (direction) {
case 'next':
nextIndex =
highlightedIndex === undefined ||
highlightedIndex === menuItems.length - 1
? menuItems.indexOf(menuItems[menuItems.length - 1])
: highlightedIndex + 1;
highlightedIndex === undefined
? 0
: highlightedIndex === menuItems.length - 1
? menuItems.length - 1
: highlightedIndex + 1;
break;
default:
nextIndex =
highlightedIndex === undefined || highlightedIndex === 0
? 0
: highlightedIndex - 1;
highlightedIndex === undefined
? menuItems.length - 1
: highlightedIndex === 0
? 0
: highlightedIndex - 1;
break;
}
console.log(highlightedIndex);
setHighlightedIndex(nextIndex);
highlight(menuItems[nextIndex] as HTMLElement);
}
Expand Down

0 comments on commit cae536f

Please sign in to comment.