Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix resolve email field error after signing in with Apple or Gmai #53109

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/components/SignInButtons/AppleSignIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ const getConfig = (config: NativeConfig, key: string, defaultValue: string) => (

type AppleSignInDivProps = {
isDesktopFlow: boolean;
onPress?: () => void;
huult marked this conversation as resolved.
Show resolved Hide resolved
};

type SingletonAppleSignInButtonProps = AppleSignInDivProps & {
isFocused: boolean;
onPress?: () => void;
huult marked this conversation as resolved.
Show resolved Hide resolved
};

type AppleSignInProps = WithNavigationFocusProps & {
Expand Down Expand Up @@ -60,7 +62,7 @@ const failureListener = (event: AppleIDSignInOnFailureEvent) => {
/**
* Apple Sign In button for Web.
*/
function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
function AppleSignInDiv({isDesktopFlow, onPress}: AppleSignInDivProps) {
huult marked this conversation as resolved.
Show resolved Hide resolved
useEffect(() => {
// `init` renders the button, so it must be called after the div is
// first mounted.
Expand Down Expand Up @@ -88,6 +90,7 @@ function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
data-width={CONST.SIGN_IN_FORM_WIDTH}
data-height="52"
style={{cursor: 'pointer'}}
onPointerDown={onPress}
huult marked this conversation as resolved.
Show resolved Hide resolved
/>
) : (
<div
Expand All @@ -99,24 +102,30 @@ function AppleSignInDiv({isDesktopFlow}: AppleSignInDivProps) {
data-border-radius="50"
data-size="40"
style={{cursor: 'pointer'}}
onPointerDown={onPress}
huult marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}

// The Sign in with Apple script may fail to render button if there are multiple
// of these divs present in the app, as it matches based on div id. So we'll
// only mount the div when it should be visible.
function SingletonAppleSignInButton({isFocused, isDesktopFlow}: SingletonAppleSignInButtonProps) {
function SingletonAppleSignInButton({isFocused, isDesktopFlow, onPress}: SingletonAppleSignInButtonProps) {
huult marked this conversation as resolved.
Show resolved Hide resolved
if (!isFocused) {
return null;
}
return <AppleSignInDiv isDesktopFlow={isDesktopFlow} />;
return (
<AppleSignInDiv
isDesktopFlow={isDesktopFlow}
onPress={onPress}
huult marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}

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

function AppleSignIn({isDesktopFlow = false}: AppleSignInProps) {
function AppleSignIn({isDesktopFlow = false, onPress}: AppleSignInProps) {
const [scriptLoaded, setScriptLoaded] = useState(false);
useEffect(() => {
if (window.appleAuthScriptLoaded) {
Expand All @@ -136,7 +145,12 @@ function AppleSignIn({isDesktopFlow = false}: AppleSignInProps) {
return null;
}

return <SingletonAppleSignInButtonWithFocus isDesktopFlow={isDesktopFlow} />;
return (
<SingletonAppleSignInButtonWithFocus
isDesktopFlow={isDesktopFlow}
onPress={onPress}
/>
);
}

AppleSignIn.displayName = 'AppleSignIn';
Expand Down
4 changes: 3 additions & 1 deletion src/components/SignInButtons/GoogleSignIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const signIn = (response: Response) => {
* @returns {React.Component}
*/

function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
function GoogleSignIn({isDesktopFlow = false, onPress}: GoogleSignInProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const loadScript = useCallback(() => {
Expand Down Expand Up @@ -76,6 +76,7 @@ function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
id={desktopId}
role={CONST.ROLE.BUTTON}
aria-label={translate('common.signInWithGoogle')}
onPointerDown={onPress}
/>
</View>
) : (
Expand All @@ -84,6 +85,7 @@ function GoogleSignIn({isDesktopFlow = false}: GoogleSignInProps) {
id={mainId}
role={CONST.ROLE.BUTTON}
aria-label={translate('common.signInWithGoogle')}
onPointerDown={onPress}
/>
</View>
);
Expand Down
Loading