From 21b2e983eb259d4fe3e00f235369da1817a963cd Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 15 Jan 2025 18:38:24 +0300 Subject: [PATCH] do not open keyboard on page load --- apps/web/components/profile/profile-field.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/web/components/profile/profile-field.tsx b/apps/web/components/profile/profile-field.tsx index d871e51..9fd187c 100644 --- a/apps/web/components/profile/profile-field.tsx +++ b/apps/web/components/profile/profile-field.tsx @@ -78,11 +78,18 @@ function useDebouncedOnChangeCallback( function useFocus(isPending: boolean) { const inputRef = useRef(null); + const [isInitialRender, setIsInitialRender] = useState(true); useEffect(() => { - if (inputRef.current) { + if (isInitialRender) { + setIsInitialRender(false); + return; + } + + if (inputRef.current && isPending) { inputRef.current.focus(); } - }, [isPending]); + }, [isInitialRender, isPending]); + return inputRef; }