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(experience): apply form default value to smart input filed #6521

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)
return true;
},
}}
render={({ field }) => (
render={({ field, formState: { defaultValues } }) => (
<SmartInputField
autoComplete="off"
autoFocus={autoFocus}
className={styles.inputField}
{...field}
defaultValue={field.value.value}
defaultValue={defaultValues?.identifier?.value}
isDanger={!!errors.identifier || !!errorMessage}
errorMessage={errors.identifier?.message}
enabledTypes={signUpMethods}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ const IdentifierSignInForm = ({ className, autoFocus, signInMethods }: Props) =>
: true;
},
}}
render={({ field }) => (
render={({ field, formState: { defaultValues } }) => (
<SmartInputField
autoFocus={autoFocus}
className={styles.inputField}
{...field}
isDanger={!!errors.identifier || !!errorMessage}
errorMessage={errors.identifier?.message}
enabledTypes={enabledSignInMethods}
defaultValue={field.value.value}
defaultValue={defaultValues?.identifier?.value}
/>
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ const PasswordSignInForm = ({ className, autoFocus, signInMethods }: Props) => {
return errorMessage ? getGeneralIdentifierErrorMessage(signInMethods, 'invalid') : true;
},
}}
render={({ field }) => (
render={({ field, formState: { defaultValues } }) => (
<SmartInputField
autoFocus={autoFocus}
className={styles.inputField}
{...field}
isDanger={!!errors.identifier}
errorMessage={errors.identifier?.message}
enabledTypes={signInMethods}
defaultValue={field.value.value}
defaultValue={defaultValues?.identifier?.value}
/>
)}
/>
Expand Down
9 changes: 7 additions & 2 deletions packages/experience/src/components/SingleSignOnForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const SingleSignOnForm = ({ isTermsAndPrivacyCheckboxVisible }: Props) => {
formState: { errors, isValid, isSubmitting },
} = useForm<FormState>({
reValidateMode: 'onBlur',
defaultValues: {
identifier: {
value: ssoEmail,
},
},
});

useEffect(() => {
Expand Down Expand Up @@ -82,13 +87,13 @@ const SingleSignOnForm = ({ isTermsAndPrivacyCheckboxVisible }: Props) => {
: true;
},
}}
render={({ field }) => (
render={({ field, formState: { defaultValues } }) => (
<SmartInputField
autoFocus
className={styles.inputField}
{...field}
isDanger={!!errors.identifier}
defaultValue={ssoEmail}
defaultValue={defaultValues?.identifier?.value}
errorMessage={errors.identifier?.message}
enabledTypes={[SignInIdentifier.Email]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ const ForgotPasswordForm = ({ className, autoFocus, defaultValue = '', enabledTy
return true;
},
}}
render={({ field }) => (
render={({ field, formState: { defaultValues } }) => (
<SmartInputField
autoFocus={autoFocus}
className={styles.inputField}
{...field}
defaultValue={defaultValue}
defaultValue={defaultValues?.identifier?.value}
isDanger={!!errors.identifier}
errorMessage={errors.identifier?.message}
enabledTypes={enabledTypes}
Expand Down
Loading