From ffda4058e0f1719375533b5a5f687be5bf616ce6 Mon Sep 17 00:00:00 2001 From: Artur Date: Thu, 11 Apr 2024 17:08:23 +0200 Subject: [PATCH] 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 --- .../modules/auth/sign-in-up/components/SignInUpForm.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx index 98b12f5ea..1825542e4 100644 --- a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx +++ b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx @@ -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 && } disabled={ - SignInUpStep.Init + signInUpStep === SignInUpStep.Init ? false : signInUpStep === SignInUpStep.Email ? !form.watch('email')