Skip to content

Commit ecaa321

Browse files
authored
Merge pull request #53109 from huult/52882-fix-apple-or-gmail-signin-email-field-error
fix resolve email field error after signing in with Apple or Gmai
2 parents 41f9122 + de3437c commit ecaa321

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/components/SignInButtons/AppleSignIn/index.tsx

+19-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const getConfig = (config: NativeConfig, key: string, defaultValue: string) => (
1616

1717
type AppleSignInDivProps = {
1818
isDesktopFlow: boolean;
19+
onPointerDown?: () => void;
1920
};
2021

2122
type SingletonAppleSignInButtonProps = AppleSignInDivProps & {
@@ -24,6 +25,7 @@ type SingletonAppleSignInButtonProps = AppleSignInDivProps & {
2425

2526
type AppleSignInProps = WithNavigationFocusProps & {
2627
isDesktopFlow?: boolean;
28+
onPointerDown?: () => void;
2729
// eslint-disable-next-line react/no-unused-prop-types
2830
onPress?: () => void;
2931
};
@@ -60,7 +62,7 @@ const failureListener = (event: AppleIDSignInOnFailureEvent) => {
6062
/**
6163
* Apple Sign In button for Web.
6264
*/
63-
function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
65+
function AppleSignInDiv({isDesktopFlow, onPointerDown}: AppleSignInDivProps) {
6466
useEffect(() => {
6567
// `init` renders the button, so it must be called after the div is
6668
// first mounted.
@@ -88,6 +90,7 @@ function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
8890
data-width={CONST.SIGN_IN_FORM_WIDTH}
8991
data-height="52"
9092
style={{cursor: 'pointer'}}
93+
onPointerDown={onPointerDown}
9194
/>
9295
) : (
9396
<div
@@ -99,24 +102,30 @@ function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
99102
data-border-radius="50"
100103
data-size="40"
101104
style={{cursor: 'pointer'}}
105+
onPointerDown={onPointerDown}
102106
/>
103107
);
104108
}
105109

106110
// The Sign in with Apple script may fail to render button if there are multiple
107111
// of these divs present in the app, as it matches based on div id. So we'll
108112
// only mount the div when it should be visible.
109-
function SingletonAppleSignInButton({isFocused, isDesktopFlow}: SingletonAppleSignInButtonProps) {
113+
function SingletonAppleSignInButton({isFocused, isDesktopFlow, onPointerDown}: SingletonAppleSignInButtonProps) {
110114
if (!isFocused) {
111115
return null;
112116
}
113-
return <AppleSignInDiv isDesktopFlow={isDesktopFlow} />;
117+
return (
118+
<AppleSignInDiv
119+
isDesktopFlow={isDesktopFlow}
120+
onPointerDown={onPointerDown}
121+
/>
122+
);
114123
}
115124

116125
// withNavigationFocus is used to only render the button when it is visible.
117126
const SingletonAppleSignInButtonWithFocus = withNavigationFocus(SingletonAppleSignInButton);
118127

119-
function AppleSignIn({isDesktopFlow = false}: AppleSignInProps) {
128+
function AppleSignIn({isDesktopFlow = false, onPointerDown}: AppleSignInProps) {
120129
const [scriptLoaded, setScriptLoaded] = useState(false);
121130
useEffect(() => {
122131
if (window.appleAuthScriptLoaded) {
@@ -136,7 +145,12 @@ function AppleSignIn({isDesktopFlow = false}: AppleSignInProps) {
136145
return null;
137146
}
138147

139-
return <SingletonAppleSignInButtonWithFocus isDesktopFlow={isDesktopFlow} />;
148+
return (
149+
<SingletonAppleSignInButtonWithFocus
150+
isDesktopFlow={isDesktopFlow}
151+
onPointerDown={onPointerDown}
152+
/>
153+
);
140154
}
141155

142156
AppleSignIn.displayName = 'AppleSignIn';

src/components/SignInButtons/GoogleSignIn/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type GoogleSignInProps = {
1111
isDesktopFlow?: boolean;
1212
// eslint-disable-next-line react/no-unused-prop-types
1313
onPress?: () => void;
14+
onPointerDown?: () => void;
1415
};
1516

1617
/** Div IDs for styling the two different Google Sign-In buttons. */
@@ -27,7 +28,7 @@ const signIn = (response: Response) => {
2728
* @returns {React.Component}
2829
*/
2930

30-
function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
31+
function GoogleSignIn({isDesktopFlow = false, onPointerDown}: GoogleSignInProps) {
3132
const {translate} = useLocalize();
3233
const styles = useThemeStyles();
3334
const loadScript = useCallback(() => {
@@ -76,6 +77,7 @@ function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
7677
id={desktopId}
7778
role={CONST.ROLE.BUTTON}
7879
aria-label={translate('common.signInWithGoogle')}
80+
onPointerDown={onPointerDown}
7981
/>
8082
</View>
8183
) : (
@@ -84,6 +86,7 @@ function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
8486
id={mainId}
8587
role={CONST.ROLE.BUTTON}
8688
aria-label={translate('common.signInWithGoogle')}
89+
onPointerDown={onPointerDown}
8790
/>
8891
</View>
8992
);

src/pages/signin/LoginForm/BaseLoginForm.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ function BaseLoginForm({login, onLoginChanged, blurOnSubmit = false, isVisible}:
220220
});
221221
}, []);
222222

223+
const handleSignIn = () => setIsSigningWithAppleOrGoogle(true);
224+
223225
return (
224226
<>
225227
<View
@@ -305,10 +307,16 @@ function BaseLoginForm({login, onLoginChanged, blurOnSubmit = false, isVisible}:
305307

306308
<View style={shouldUseNarrowLayout ? styles.loginButtonRowSmallScreen : styles.loginButtonRow}>
307309
<View>
308-
<AppleSignIn onPress={() => setIsSigningWithAppleOrGoogle(true)} />
310+
<AppleSignIn
311+
onPress={handleSignIn}
312+
onPointerDown={handleSignIn}
313+
/>
309314
</View>
310315
<View>
311-
<GoogleSignIn onPress={() => setIsSigningWithAppleOrGoogle(true)} />
316+
<GoogleSignIn
317+
onPress={handleSignIn}
318+
onPointerDown={handleSignIn}
319+
/>
312320
</View>
313321
</View>
314322
</View>

0 commit comments

Comments
 (0)