From 838c5f3dd6c2c80b0dedff5f5c936c80bcf6be0a Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Thu, 18 Apr 2024 15:27:51 +0200 Subject: [PATCH] Fix scrolling to last index in SelectionList using keyboard --- 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);