From 8a78762b95c2a4f4acbeb2730d8fe93c283d521f Mon Sep 17 00:00:00 2001 From: William Grant Date: Thu, 14 Mar 2024 16:39:31 +1100 Subject: [PATCH] fix: disable inputs when button is disabled --- ts/components/registration/stages/CreateAccount.tsx | 4 ++++ ts/components/registration/stages/RestoreAccount.tsx | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ts/components/registration/stages/CreateAccount.tsx b/ts/components/registration/stages/CreateAccount.tsx index 437ad5a53..e862b0200 100644 --- a/ts/components/registration/stages/CreateAccount.tsx +++ b/ts/components/registration/stages/CreateAccount.tsx @@ -58,6 +58,10 @@ export const CreateAccount = () => { }, [step, hexGeneratedPubKey]); const signUpWithDetails = async () => { + if (!(!!displayName && !displayNameError)) { + return; + } + try { await signUp({ displayName, diff --git a/ts/components/registration/stages/RestoreAccount.tsx b/ts/components/registration/stages/RestoreAccount.tsx index 3c0eddcb5..c4bdef637 100644 --- a/ts/components/registration/stages/RestoreAccount.tsx +++ b/ts/components/registration/stages/RestoreAccount.tsx @@ -114,6 +114,10 @@ export const RestoreAccount = () => { useRecoveryProgressEffect({ step, progress, setProgress, displayName, dispatch }); const recoverAndFetchDisplayName = async () => { + if (!(!!recoveryPassword && !recoveryPasswordError)) { + return; + } + setProgress(0); try { const displayNameFromNetwork = await signInAndFetchDisplayName({ @@ -150,6 +154,10 @@ export const RestoreAccount = () => { }; const recoverAndEnterDisplayName = async () => { + if (!(!!recoveryPassword && !recoveryPasswordError) || !(!!displayName && !displayNameError)) { + return; + } + setProgress(0); try { await signInWithNewDisplayName({ @@ -244,7 +252,6 @@ export const RestoreAccount = () => { onClick={recoverAndEnterDisplayName} text={window.i18n('continue')} disabled={ - // TODO Fix that even if there is an error we only care if there is something in the input check Create Account !(!!recoveryPassword && !recoveryPasswordError) || !(!!displayName && !displayNameError) }