fix(SW-360): change button to signup to trigger shouldFocusError
This commit is contained in:
@@ -79,17 +79,6 @@ export default function SignupForm({ link, subtitle, title }: SignUpFormProps) {
|
|||||||
signup.mutate({ ...data, language: lang })
|
signup.mutate({ ...data, language: lang })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleValidation() {
|
|
||||||
const result = await methods.trigger()
|
|
||||||
if (!result) {
|
|
||||||
// Get first error field and focus on it.
|
|
||||||
const firstError = Object.keys(methods.formState.errors)[0]
|
|
||||||
if (firstError) {
|
|
||||||
methods.setFocus(firstError as keyof SignUpSchema)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.formWrapper}>
|
<section className={styles.formWrapper}>
|
||||||
<Title as="h3">{title}</Title>
|
<Title as="h3">{title}</Title>
|
||||||
@@ -198,10 +187,10 @@ export default function SignupForm({ link, subtitle, title }: SignUpFormProps) {
|
|||||||
{!methods.formState.isValid ? (
|
{!methods.formState.isValid ? (
|
||||||
<Button
|
<Button
|
||||||
className={styles.signUpButton}
|
className={styles.signUpButton}
|
||||||
type="button"
|
type="submit"
|
||||||
theme="base"
|
theme="base"
|
||||||
intent="primary"
|
intent="primary"
|
||||||
onClick={handleValidation}
|
onClick={() => methods.trigger()}
|
||||||
data-testid="trigger-validation"
|
data-testid="trigger-validation"
|
||||||
>
|
>
|
||||||
{signupButtonText}
|
{signupButtonText}
|
||||||
|
|||||||
Reference in New Issue
Block a user