From 05811a4e04f012802c6a53de30d30c12382a8d3e Mon Sep 17 00:00:00 2001 From: Hoa Phan Date: Mon, 25 Mar 2024 22:03:47 +0700 Subject: [PATCH] fix: scrollToIndex out of range: item length 0 but minimum is 1 --- src/components/Dropdown/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Dropdown/index.tsx b/src/components/Dropdown/index.tsx index b5bb13c..a67f1e4 100644 --- a/src/components/Dropdown/index.tsx +++ b/src/components/Dropdown/index.tsx @@ -253,7 +253,11 @@ const DropdownComponent: ( 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,