Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: IOU - Currency listing page displays empty when clicked on currency #42816

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/hooks/useArrowKeyFocusManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useCallback, useEffect, useMemo, useState} from 'react';
import CONST from '@src/CONST';
import useKeyboardShortcut from './useKeyboardShortcut';
import usePrevious from './usePrevious';

type Config = {
maxIndex: number;
Expand Down Expand Up @@ -51,6 +52,7 @@ export default function useArrowKeyFocusManager({
isFocused = true,
}: Config): UseArrowKeyFocusManager {
const [focusedIndex, setFocusedIndex] = useState(initialFocusedIndex);
const prevIsFocusedIndex = usePrevious(focusedIndex);
const arrowConfig = useMemo(
() => ({
excludedNodes: shouldExcludeTextAreaNodes ? ['TEXTAREA'] : [],
Expand All @@ -67,8 +69,13 @@ export default function useArrowKeyFocusManager({
[isActive, shouldExcludeTextAreaNodes, allowHorizontalArrowKeys],
);

// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(() => onFocusedIndexChange(focusedIndex), [focusedIndex]);
useEffect(() => {
if (prevIsFocusedIndex === focusedIndex) {
return;
}
onFocusedIndexChange(focusedIndex);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [focusedIndex, prevIsFocusedIndex]);

const arrowUpCallback = useCallback(() => {
if (maxIndex < 0 || !isFocused) {
Expand Down
Loading