From a1a1582b14e4bcd91b575d04b7db2a8968ceec47 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:23:10 -0700 Subject: [PATCH] Merge pull request #40439 from software-mansion-labs/fix/scroll-to-last-index-with-keyboard Fix scrolling to last index in SelectionList using keyboard (cherry picked from commit 985591f48a7fc34fdd2eb68172bc3748112cf20d) --- src/components/SelectionList/BaseSelectionList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SelectionList/BaseSelectionList.tsx b/src/components/SelectionList/BaseSelectionList.tsx index b24fe5351fad..9ab89aa73f86 100644 --- a/src/components/SelectionList/BaseSelectionList.tsx +++ b/src/components/SelectionList/BaseSelectionList.tsx @@ -228,7 +228,7 @@ function BaseSelectionList( // If `initiallyFocusedOptionKey` is not passed, we fall back to `-1`, to avoid showing the highlight on the first member const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({ initialFocusedIndex: flattenedSections.allOptions.findIndex((option) => option.keyForList === initiallyFocusedOptionKey), - maxIndex: flattenedSections.allOptions.length - 1, + maxIndex: Math.min(flattenedSections.allOptions.length, CONST.MAX_OPTIONS_SELECTOR_PAGE_LENGTH * currentPage - 1), isActive: true, onFocusedIndexChange: (index: number) => { scrollToIndex(index, true);