fix(SW-360): scroll to first validation + remove unused translations

This commit is contained in:
Chuma McPhoy
2024-11-25 10:26:18 +01:00
parent 03db7cec16
commit 79f48adbf5
6 changed files with 12 additions and 6 deletions

View File

@@ -79,6 +79,17 @@ 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>
@@ -190,7 +201,7 @@ export default function SignupForm({ link, subtitle, title }: SignUpFormProps) {
type="button"
theme="base"
intent="primary"
onClick={() => methods.trigger()}
onClick={handleValidation}
data-testid="trigger-validation"
>
{signupButtonText}