Skip to content

Commit

Permalink
fix: wrappe initial focus into memo
Browse files Browse the repository at this point in the history
  • Loading branch information
barttom committed Nov 7, 2023
1 parent efd8532 commit 6679b76
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/SelectionList/BaseSelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ function BaseSelectionList({

// If `initiallyFocusedOptionKey` is not passed, we fall back to `-1`, to avoid showing the highlight on the first member
const [focusedIndex, setFocusedIndex] = useState(() => _.findIndex(flattenedSections.allOptions, (option) => option.keyForList === initiallyFocusedOptionKey));
const initialFocusedIndex = focusedIndex > -1 ? focusedIndex : undefined;
// initialFocusedIndex is needed only on component did mount event, don't need to update value
// eslint-disable-next-line react-hooks/exhaustive-deps
const initialFocusedIndex = useMemo(() => (focusedIndex > -1 ? focusedIndex : undefined), []);

// Disable `Enter` shortcut if the active element is a button or checkbox
const disableEnterShortcut = activeElement && [CONST.ACCESSIBILITY_ROLE.BUTTON, CONST.ACCESSIBILITY_ROLE.CHECKBOX].includes(activeElement.role);
Expand Down

0 comments on commit 6679b76

Please sign in to comment.