From 80cfde67f5699aad02cc45b3506ccbb65a7cc888 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 31 Mar 2025 22:12:03 +0700 Subject: [PATCH 1/2] fix: start chat page is broken after refreshing the page --- src/hooks/useAutoFocusInput.ts | 10 +++++++--- src/hooks/useSidePane.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hooks/useAutoFocusInput.ts b/src/hooks/useAutoFocusInput.ts index 4ddf421af48d..534e8d05d45a 100644 --- a/src/hooks/useAutoFocusInput.ts +++ b/src/hooks/useAutoFocusInput.ts @@ -7,6 +7,7 @@ import {moveSelectionToEnd, scrollToBottom} from '@libs/InputUtils'; import CONST from '@src/CONST'; import {useSplashScreenStateContext} from '@src/SplashScreenStateContext'; import useSidePane from './useSidePane'; +import usePrevious from './usePrevious'; type UseAutoFocusInput = { inputCallbackRef: (ref: TextInput | null) => void; @@ -56,13 +57,16 @@ export default function useAutoFocusInput(isMultiline = false): UseAutoFocusInpu // Trigger focus when side pane transition ends const {isSidePaneTransitionEnded, shouldHideSidePane} = useSidePane(); + const prevShouldHideSidePane = usePrevious(shouldHideSidePane); useEffect(() => { - if (!shouldHideSidePane) { + if (!shouldHideSidePane || prevShouldHideSidePane) { return; } - + setIsScreenTransitionEnded(isSidePaneTransitionEnded); - }, [isSidePaneTransitionEnded, shouldHideSidePane]); + }, [isSidePaneTransitionEnded, shouldHideSidePane, prevShouldHideSidePane]); + + const inputCallbackRef = (ref: TextInput | null) => { inputRef.current = ref; diff --git a/src/hooks/useSidePane.ts b/src/hooks/useSidePane.ts index d0d579086bd6..ea03c65aa35d 100644 --- a/src/hooks/useSidePane.ts +++ b/src/hooks/useSidePane.ts @@ -56,7 +56,7 @@ function useSidePane() { const {windowWidth} = useWindowDimensions(); const sidePaneWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth; - const [isSidePaneTransitionEnded, setIsSidePaneTransitionEnded] = useState(true); + const [isSidePaneTransitionEnded, setIsSidePaneTransitionEnded] = useState(false); const {shouldHideSidePane, shouldHideSidePaneBackdrop, shouldHideHelpButton, sidePaneNVP} = useSidePaneDisplayStatus(); const shouldHideToolTip = isExtraLargeScreenWidth ? !isSidePaneTransitionEnded : !shouldHideSidePane; From 0f7ddb780a27769916b995f8fb35b04aa5e0373e Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Mon, 31 Mar 2025 22:22:06 +0700 Subject: [PATCH 2/2] run prettier --- src/hooks/useAutoFocusInput.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hooks/useAutoFocusInput.ts b/src/hooks/useAutoFocusInput.ts index 534e8d05d45a..ddc74aecd523 100644 --- a/src/hooks/useAutoFocusInput.ts +++ b/src/hooks/useAutoFocusInput.ts @@ -6,8 +6,8 @@ import {InteractionManager} from 'react-native'; import {moveSelectionToEnd, scrollToBottom} from '@libs/InputUtils'; import CONST from '@src/CONST'; import {useSplashScreenStateContext} from '@src/SplashScreenStateContext'; -import useSidePane from './useSidePane'; import usePrevious from './usePrevious'; +import useSidePane from './useSidePane'; type UseAutoFocusInput = { inputCallbackRef: (ref: TextInput | null) => void; @@ -62,12 +62,10 @@ export default function useAutoFocusInput(isMultiline = false): UseAutoFocusInpu if (!shouldHideSidePane || prevShouldHideSidePane) { return; } - + setIsScreenTransitionEnded(isSidePaneTransitionEnded); }, [isSidePaneTransitionEnded, shouldHideSidePane, prevShouldHideSidePane]); - - const inputCallbackRef = (ref: TextInput | null) => { inputRef.current = ref; if (isInputInitialized) {