Skip to content

Commit a779f7d

Browse files
authored
Merge pull request #42816 from nkdengineer/fix/40483
fix: IOU - Currency listing page displays empty when clicked on currency
2 parents 81caf98 + d6adc86 commit a779f7d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/hooks/useArrowKeyFocusManager.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {useCallback, useEffect, useMemo, useState} from 'react';
22
import CONST from '@src/CONST';
33
import useKeyboardShortcut from './useKeyboardShortcut';
4+
import usePrevious from './usePrevious';
45

56
type Config = {
67
maxIndex: number;
@@ -51,6 +52,7 @@ export default function useArrowKeyFocusManager({
5152
isFocused = true,
5253
}: Config): UseArrowKeyFocusManager {
5354
const [focusedIndex, setFocusedIndex] = useState(initialFocusedIndex);
55+
const prevIsFocusedIndex = usePrevious(focusedIndex);
5456
const arrowConfig = useMemo(
5557
() => ({
5658
excludedNodes: shouldExcludeTextAreaNodes ? ['TEXTAREA'] : [],
@@ -67,8 +69,13 @@ export default function useArrowKeyFocusManager({
6769
[isActive, shouldExcludeTextAreaNodes, allowHorizontalArrowKeys],
6870
);
6971

70-
// eslint-disable-next-line react-hooks/exhaustive-deps
71-
useEffect(() => onFocusedIndexChange(focusedIndex), [focusedIndex]);
72+
useEffect(() => {
73+
if (prevIsFocusedIndex === focusedIndex) {
74+
return;
75+
}
76+
onFocusedIndexChange(focusedIndex);
77+
// eslint-disable-next-line react-hooks/exhaustive-deps
78+
}, [focusedIndex, prevIsFocusedIndex]);
7279

7380
const arrowUpCallback = useCallback(() => {
7481
if (maxIndex < 0 || !isFocused) {

0 commit comments

Comments
 (0)