Skip to content

Commit

Permalink
Merge pull request Expensify#34495 from callstack-internal/fix/start-…
Browse files Browse the repository at this point in the history
…chat-tabs-transition

Fix StartChat screen transition stuttering
  • Loading branch information
robertjchen authored Feb 2, 2024
2 parents cc64ab0 + d6029f2 commit d9fd412
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hooks/useAutoFocusInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
}, []),
);

Expand Down

0 comments on commit d9fd412

Please sign in to comment.