Skip to content

Commit

Permalink
Merge pull request #54962 from daledah/fix/54931
Browse files Browse the repository at this point in the history
[CP Staging] fix: unable to change currency with arrow key

(cherry picked from commit 9589f64)

(CP triggered by mountiny)
  • Loading branch information
mountiny authored and OSBotify committed Jan 8, 2025
1 parent 006a164 commit e0789a6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,15 @@ function BaseSelectionList<TItem extends ListItem>(
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?.('');
Expand Down

0 comments on commit e0789a6

Please sign in to comment.