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
  • Loading branch information
mountiny authored Jan 8, 2025
2 parents cc8fcc3 + 8924bc7 commit 9589f64
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 9589f64

Please sign in to comment.