From 8924bc7f64d276804a7ecb1ee8433275456713f6 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 8 Jan 2025 21:26:11 +0700 Subject: [PATCH] fix: unable to change currency with arrow key --- src/components/SelectionList/BaseSelectionList.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index 84b91beac623..ea065c61a9be 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -333,14 +333,15 @@ function BaseSelectionList( isFocused, }); + const selectedItemIndex = useMemo(() => flattenedSections.allOptions.findIndex((option) => option.isSelected), [flattenedSections.allOptions]); + useEffect(() => { - const selectedItemIndex = flattenedSections.allOptions.findIndex((option) => option.isSelected); if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) { return; } setFocusedIndex(selectedItemIndex); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - }, [flattenedSections]); + }, [selectedItemIndex]); const clearInputAfterSelect = useCallback(() => { onChangeText?.('');