Skip to content

Commit

Permalink
fix: scrollToIndex out of range: item length 0 but minimum is 1
Browse files Browse the repository at this point in the history
  • Loading branch information
hoaphantn7604 committed Mar 25, 2024
1 parent 1dccf5f commit 05811a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ const DropdownComponent: <T>(
const index = _.findIndex(listData, (e: any) =>
_.isEqual(defaultValue, _.get(e, valueField))
);
if (index > -1 && index <= listData.length - 1) {
if (
!_.isEmpty(listData.length) &&
index > -1 &&
index <= listData.length - 1
) {
refList?.current?.scrollToIndex({
index: index,
animated: false,
Expand Down

0 comments on commit 05811a4

Please sign in to comment.