Skip to content

Commit 05811a4

Browse files
committed
fix: scrollToIndex out of range: item length 0 but minimum is 1
1 parent 1dccf5f commit 05811a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/Dropdown/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ const DropdownComponent: <T>(
253253
const index = _.findIndex(listData, (e: any) =>
254254
_.isEqual(defaultValue, _.get(e, valueField))
255255
);
256-
if (index > -1 && index <= listData.length - 1) {
256+
if (
257+
!_.isEmpty(listData.length) &&
258+
index > -1 &&
259+
index <= listData.length - 1
260+
) {
257261
refList?.current?.scrollToIndex({
258262
index: index,
259263
animated: false,

0 commit comments

Comments
 (0)