Skip to content

Commit

Permalink
fix: out of bound index (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
timc1 authored Oct 27, 2021
1 parent ab55f10 commit bbd7af2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/KBarResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const KBarResults: React.FC<KBarResultsProps> = (props) => {
let nextIndex = index > START_INDEX ? index - 1 : index;
// avoid setting active index on a group
if (typeof itemsRef.current[nextIndex] === "string") {
if (nextIndex === 0) return index;
nextIndex -= 1;
}
return nextIndex;
Expand All @@ -60,6 +61,7 @@ const KBarResults: React.FC<KBarResultsProps> = (props) => {
index < itemsRef.current.length - 1 ? index + 1 : index;
// avoid setting active index on a group
if (typeof itemsRef.current[nextIndex] === "string") {
if (nextIndex === itemsRef.current.length - 1) return index;
nextIndex += 1;
}
return nextIndex;
Expand Down

1 comment on commit bbd7af2

@vercel
Copy link

@vercel vercel bot commented on bbd7af2 Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.