Skip to content

Commit

Permalink
Fix pressing up with all options disabled underflowing
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-knight committed Jan 21, 2022
1 parent 452d917 commit 598f1c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
const len = memoFlattenOptions.length;

for (let i = 0; i < len; i += 1) {
const current = (index + i * offset + len) % len;
// Use `len * 2` because if all the options are disabled `index + i * offset + len` can be < 0 (but > -len)
const current = (index + i * offset + len * 2) % len;

const { group, data } = memoFlattenOptions[current];
if (!group && !data.disabled) {
Expand Down

0 comments on commit 598f1c4

Please sign in to comment.