From 0cb3d0cd2ff13b455e90f69b85719ebd214eca91 Mon Sep 17 00:00:00 2001 From: sourcecodedeveloper Date: Thu, 21 Dec 2023 00:48:26 -0800 Subject: [PATCH 1/5] resolve magic code sent twice --- src/pages/signin/LoginForm/BaseLoginForm.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index aa158d66a936..c60194e04d40 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -99,6 +99,7 @@ function LoginForm(props) { const prevIsVisible = usePrevious(props.isVisible); const firstBlurred = useRef(false); const isFocused = useIsFocused(); + const isLoading = useRef(false); const {translate} = props; @@ -168,6 +169,7 @@ function LoginForm(props) { if (props.network.isOffline || props.account.isLoading) { return; } + isLoading.current = true; // If account was closed and have success message in Onyx, we clear it here if (!_.isEmpty(props.closeAccount.success)) { @@ -223,13 +225,15 @@ function LoginForm(props) { if (props.blurOnSubmit) { input.current.blur(); } - + if (props.account.isLoading === false) { + isLoading.current = false; + } // Only focus the input if the form becomes visible again, to prevent the keyboard from automatically opening on touchscreen devices after signing out if (!input.current || prevIsVisible || !props.isVisible) { return; } input.current.focus(); - }, [props.blurOnSubmit, props.isVisible, prevIsVisible]); + }, [props.blurOnSubmit, props.isVisible, prevIsVisible, props.account.isLoading]); useImperativeHandle(props.innerRef, () => ({ isInputFocused() { From f2b4a9b532729a654615ce51ef61fc7495176eaf Mon Sep 17 00:00:00 2001 From: sourcecodedeveloper Date: Thu, 21 Dec 2023 03:23:49 -0800 Subject: [PATCH 2/5] include loading check --- src/pages/signin/LoginForm/BaseLoginForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index c60194e04d40..de86b4c0fd58 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -166,7 +166,7 @@ function LoginForm(props) { * Check that all the form fields are valid, then trigger the submit callback */ const validateAndSubmitForm = useCallback(() => { - if (props.network.isOffline || props.account.isLoading) { + if (props.network.isOffline || props.account.isLoading || isLoading.current) { return; } isLoading.current = true; From 1acf4f772a0bb28c82a78d17ffec6fea7428a859 Mon Sep 17 00:00:00 2001 From: sourcecodedeveloper Date: Sun, 24 Dec 2023 13:18:06 -0800 Subject: [PATCH 3/5] add seperate useEffect --- src/pages/signin/LoginForm/BaseLoginForm.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index de86b4c0fd58..e5cac66ba248 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -221,19 +221,23 @@ function LoginForm(props) { // eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to call this function when component is mounted }, []); + useEffect(() => { + if (props.account.isLoading !== false) { + return; + } + isLoading.current = false; + }, [props.account.isLoading]); + useEffect(() => { if (props.blurOnSubmit) { input.current.blur(); } - if (props.account.isLoading === false) { - isLoading.current = false; - } // Only focus the input if the form becomes visible again, to prevent the keyboard from automatically opening on touchscreen devices after signing out if (!input.current || prevIsVisible || !props.isVisible) { return; } input.current.focus(); - }, [props.blurOnSubmit, props.isVisible, prevIsVisible, props.account.isLoading]); + }, [props.blurOnSubmit, props.isVisible, prevIsVisible]); useImperativeHandle(props.innerRef, () => ({ isInputFocused() { From ac3e5f83c98896385dd77e9cd689b0bfb2a2d843 Mon Sep 17 00:00:00 2001 From: sourcecodedeveloper Date: Sun, 24 Dec 2023 13:58:58 -0800 Subject: [PATCH 4/5] set isloading to false --- src/pages/signin/LoginForm/BaseLoginForm.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index e5cac66ba248..5803f352ad4c 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -183,6 +183,7 @@ function LoginForm(props) { } if (!validate(login)) { + isLoading.current = false; return; } @@ -232,6 +233,7 @@ function LoginForm(props) { if (props.blurOnSubmit) { input.current.blur(); } + // Only focus the input if the form becomes visible again, to prevent the keyboard from automatically opening on touchscreen devices after signing out if (!input.current || prevIsVisible || !props.isVisible) { return; From bebd1c4355f255ee2d20bebe3d76b9e06dc28e9e Mon Sep 17 00:00:00 2001 From: sourcecodedeveloper Date: Sun, 24 Dec 2023 14:41:16 -0800 Subject: [PATCH 5/5] resolve lint --- src/pages/signin/LoginForm/BaseLoginForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index 5803f352ad4c..64f4e93011c5 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -233,7 +233,7 @@ function LoginForm(props) { if (props.blurOnSubmit) { input.current.blur(); } - + // Only focus the input if the form becomes visible again, to prevent the keyboard from automatically opening on touchscreen devices after signing out if (!input.current || prevIsVisible || !props.isVisible) { return;