Skip to content

Commit

Permalink
Merge branch 'main' into ci-close-stale
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq authored Jul 26, 2023
2 parents 220bb93 + 17f6ed4 commit 734ccdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/elements/src/contexts/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ interface Context extends States {
enablePasskeys: boolean;
lang: string;
hidePasskeyButtonOnLogin: boolean;
prefilledEmail: string;
prefilledEmail?: string;
}

export const AppContext = createContext<Context>(null);
Expand Down
9 changes: 7 additions & 2 deletions frontend/elements/src/pages/LoginEmailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const LoginEmailPage = (props: Props) => {
} = useContext(AppContext);

const [emailAddress, setEmailAddress] = useState<string>(
props.emailAddress || prefilledEmail
props.emailAddress || prefilledEmail || ""
);
const [isPasskeyLoginLoading, setIsPasskeyLoginLoading] = useState<boolean>();
const [isPasskeyLoginSuccess, setIsPasskeyLoginSuccess] = useState<boolean>();
Expand Down Expand Up @@ -387,7 +387,12 @@ const LoginEmailPage = (props: Props) => {
}, [hanko, setPage, isThirdPartyLoginLoading]);

useEffect(() => {
setEmailAddress(prefilledEmail);
if (emailAddress.length === 0 && prefilledEmail !== undefined) {
setEmailAddress(prefilledEmail);
}
// The dependency array is missing the emailAddress parameter intentionally because if it is not missing the email
// would always be reset to the prefilledEmail when the input is empty
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [prefilledEmail]);

return (
Expand Down

0 comments on commit 734ccdd

Please sign in to comment.