From 944a29b6bb9d451a7c01f42bdcdb70af68c9f357 Mon Sep 17 00:00:00 2001 From: Fitsum Abebe Date: Mon, 5 Feb 2024 14:52:51 +0300 Subject: [PATCH] updated based on comments --- src/pages/signin/LoginForm/BaseLoginForm.js | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index b126219e44db..6cbef7da7f3f 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -28,7 +28,7 @@ import {parsePhoneNumber} from '@libs/PhoneNumber'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; import Visibility from '@libs/Visibility'; -import willBlurTextInputOnTapOutside from '@libs/willBlurTextInputOnTapOutside'; +import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside'; import * as CloseAccount from '@userActions/CloseAccount'; import * as MemoryOnlyKeys from '@userActions/MemoryOnlyKeys/MemoryOnlyKeys'; import * as Session from '@userActions/Session'; @@ -92,6 +92,8 @@ const defaultProps = { isInModal: false, }; +const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc(); + function LoginForm(props) { const styles = useThemeStyles(); const input = useRef(); @@ -282,17 +284,18 @@ function LoginForm(props) { // As we have only two signin buttons (Apple/Google) other than the text input, // for natives onBlur is called only when the buttons are pressed and we don't need // to validate in those case as the user has opted for other signin flow. - willBlurTextInputOnTapOutside() && - (() => - // This delay is to avoid the validate being called before google iframe is rendered to - // avoid error message appearing after pressing google signin button. - setTimeout(() => { - if (firstBlurred.current || !Visibility.isVisible() || !Visibility.hasFocus()) { - return; - } - firstBlurred.current = true; - validate(login); - }, 500)) + willBlurTextInputOnTapOutside + ? () => + // This delay is to avoid the validate being called before google iframe is rendered to + // avoid error message appearing after pressing google signin button. + setTimeout(() => { + if (firstBlurred.current || !Visibility.isVisible() || !Visibility.hasFocus()) { + return; + } + firstBlurred.current = true; + validate(login); + }, 500) + : undefined } onChangeText={onTextInput} onSubmitEditing={validateAndSubmitForm}