Skip to content

Commit

Permalink
Merge pull request #34863 from FitseTLT/fix-google-signin-validate-er…
Browse files Browse the repository at this point in the history
…ror-bug

Fix error message display bug on google signin
  • Loading branch information
roryabraham authored Feb 5, 2024
2 parents 554276f + 944a29b commit 51f0a00
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/pages/signin/LoginForm/BaseLoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -91,6 +92,8 @@ const defaultProps = {
isInModal: false,
};

const willBlurTextInputOnTapOutside = willBlurTextInputOnTapOutsideFunc();

function LoginForm(props) {
const styles = useThemeStyles();
const input = useRef();
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -333,10 +346,10 @@ function LoginForm(props) {
</Text>

<View style={props.isSmallScreenWidth ? styles.loginButtonRowSmallScreen : styles.loginButtonRow}>
<View onMouseDown={(e) => e.preventDefault()}>
<View>
<AppleSignIn />
</View>
<View onMouseDown={(e) => e.preventDefault()}>
<View>
<GoogleSignIn />
</View>
</View>
Expand Down

0 comments on commit 51f0a00

Please sign in to comment.