diff --git a/src/hooks/useAutoFocusInput.ts b/src/hooks/useAutoFocusInput.ts index 20d0dee1f407..e8e7c1187a63 100644 --- a/src/hooks/useAutoFocusInput.ts +++ b/src/hooks/useAutoFocusInput.ts @@ -23,10 +23,14 @@ export default function useAutoFocusInput(): UseAutoFocusInput { if (!isScreenTransitionEnded || !isInputInitialized || !inputRef.current || !isSplashHidden) { return; } - InteractionManager.runAfterInteractions(() => { + const focusTaskHandle = InteractionManager.runAfterInteractions(() => { inputRef.current?.focus(); setIsScreenTransitionEnded(false); }); + + return () => { + focusTaskHandle.cancel(); + }; }, [isScreenTransitionEnded, isInputInitialized, isSplashHidden]); useFocusEffect( @@ -35,12 +39,12 @@ export default function useAutoFocusInput(): UseAutoFocusInput { setIsScreenTransitionEnded(true); }, CONST.ANIMATED_TRANSITION); return () => { + setIsScreenTransitionEnded(false); if (!focusTimeoutRef.current) { return; } clearTimeout(focusTimeoutRef.current); }; - // eslint-disable-next-line react-hooks/exhaustive-deps }, []), );