4809 - disable double signup with mouse click / enter (#4878)

Fixing #4809 

The form has a button with a disabled condition, unfortunately there was
an error in checking the condition.
```
disabled={
       SignInUpStep.Init
                ? false
                ...
```
SignInUpStep.Init is always equal to true, so the first arm was
returning false and button was never disabled. Fixing this check fixes
the double mouse click bug as expected.
```
disabled={
              signInUpStep === SignInUpStep.Init
```

Still, the enter keypress is handled a little bit differently. There is
a handleKeyDown event that was ignoring if the form is submitting or
not. I added the check for that, and now pressing enter multiple times
does not result in any errors
This commit is contained in:
Artur 2024-04-11 17:08:23 +02:00 committed by GitHub
parent bf60227d67
commit ffda4058e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,8 +71,10 @@ export const SignInUpForm = () => {
} else if (signInUpStep === SignInUpStep.Email) {
continueWithCredentials();
} else if (signInUpStep === SignInUpStep.Password) {
setShowErrors(true);
form.handleSubmit(submitCredentials)();
if (!form.formState.isSubmitting) {
setShowErrors(true);
form.handleSubmit(submitCredentials)();
}
}
}
};
@ -225,7 +227,7 @@ export const SignInUpForm = () => {
}}
Icon={() => form.formState.isSubmitting && <Loader />}
disabled={
SignInUpStep.Init
signInUpStep === SignInUpStep.Init
? false
: signInUpStep === SignInUpStep.Email
? !form.watch('email')