Skip to content

Commit

Permalink
Merge pull request #40439 from software-mansion-labs/fix/scroll-to-la…
Browse files Browse the repository at this point in the history
…st-index-with-keyboard

Fix scrolling to last index in SelectionList using keyboard

(cherry picked from commit 985591f)
  • Loading branch information
roryabraham authored and OSBotify committed Apr 19, 2024
1 parent f9fc6ee commit a1a1582
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function BaseSelectionList<TItem extends ListItem>(
// 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);
Expand Down

0 comments on commit a1a1582

Please sign in to comment.