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