diff --git a/src/pages/signin/LoginForm/BaseLoginForm.js b/src/pages/signin/LoginForm/BaseLoginForm.js index a7e2b5ee07fb..6cbef7da7f3f 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.js +++ b/src/pages/signin/LoginForm/BaseLoginForm.js @@ -28,6 +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 willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside'; import * as CloseAccount from '@userActions/CloseAccount'; import * as MemoryOnlyKeys from '@userActions/MemoryOnlyKeys/MemoryOnlyKeys'; import * as Session from '@userActions/Session'; @@ -91,6 +92,8 @@ const defaultProps = { isInModal: false, }; +const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc(); + function LoginForm(props) { const styles = useThemeStyles(); const input = useRef(); @@ -277,13 +280,23 @@ function LoginForm(props) { id="username" name="username" testID="username" - onBlur={() => { - if (firstBlurred.current || !Visibility.isVisible() || !Visibility.hasFocus()) { - return; - } - firstBlurred.current = true; - validate(login); - }} + onBlur={ + // 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) + : undefined + } onChangeText={onTextInput} onSubmitEditing={validateAndSubmitForm} autoCapitalize="none" @@ -333,10 +346,10 @@ function LoginForm(props) { - e.preventDefault()}> + - e.preventDefault()}> +