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 })
|
||||
}
|
||||
|
||||
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 (
|
||||
<section className={styles.formWrapper}>
|
||||
<Title as="h3">{title}</Title>
|
||||
@@ -198,10 +187,10 @@ export default function SignupForm({ link, subtitle, title }: SignUpFormProps) {
|
||||
{!methods.formState.isValid ? (
|
||||
<Button
|
||||
className={styles.signUpButton}
|
||||
type="button"
|
||||
type="submit"
|
||||
theme="base"
|
||||
intent="primary"
|
||||
onClick={handleValidation}
|
||||
onClick={() => methods.trigger()}
|
||||
data-testid="trigger-validation"
|
||||
>
|
||||
{signupButtonText}
|
||||
|
||||
Reference in New Issue
Block a user