Skip to content

Commit

Permalink
fix: check args passed to scrollIntoView
Browse files Browse the repository at this point in the history
  • Loading branch information
nieyuyao committed Apr 13, 2022
1 parent d88450f commit 18e8f47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/OptionList.tsx
Expand Up @@ -77,7 +77,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP

const scrollIntoView = (args: number | ScrollConfig) => {
if (listRef.current) {
listRef.current.scrollTo(args);
listRef.current.scrollTo(typeof args === 'number' ? { index: args } : args);
}
};

Expand Down Expand Up @@ -137,7 +137,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP

if (index !== -1) {
setActive(index);
scrollIntoView({ index });
scrollIntoView(index);
}
}
});
Expand Down Expand Up @@ -187,7 +187,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP

if (offset !== 0) {
const nextActiveIndex = getEnabledActiveIndex(activeIndex + offset, offset);
scrollIntoView({ index: nextActiveIndex });
scrollIntoView(nextActiveIndex);
setActive(nextActiveIndex, true);
}

Expand Down

0 comments on commit 18e8f47

Please sign in to comment.