From 129b587ae375b3282893ee78de39ce690d4a4cfa Mon Sep 17 00:00:00 2001 From: Francois Touchard Date: Mon, 2 Dec 2024 17:35:00 +0100 Subject: [PATCH] fix(auth): MB-2996, fixing unwanted submit on first name input --- .../modules/auth/templates/forgot/screen.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/framework/modules/auth/templates/forgot/screen.tsx b/src/framework/modules/auth/templates/forgot/screen.tsx index eb386fba4..bf7805acb 100644 --- a/src/framework/modules/auth/templates/forgot/screen.tsx +++ b/src/framework/modules/auth/templates/forgot/screen.tsx @@ -51,10 +51,13 @@ export const ForgotPage: React.FC = (props: ForgotScre const hasStructures = structures.length > 0; const isError = result && containsKey(result, 'error'); const errorMsg = isError ? (result as { error: string }).error : null; - const canSubmit = - forgotMode === 'id' && hasStructures - ? !firstName || !selectedStructureName || !login - : !login || (forgotMode === 'id' && !isValidEmail) || (isError && !editing); + const canSubmit = React.useMemo( + () => + forgotMode === 'password' + ? !login || (isError && !editing) + : !isValidEmail || (hasStructures && (!firstName || !selectedSructureId)), + [forgotMode, login, isValidEmail, hasStructures, firstName, selectedSructureId], + ); const errorText = hasStructures ? I18n.get('auth-forgot-severalemails') : errorMsg @@ -138,7 +141,7 @@ export const ForgotPage: React.FC = (props: ForgotScre editable={!hasStructures} returnKeyLabel={I18n.get('auth-forgot-submit')} returnKeyType="done" - onSubmitEditing={() => doSubmit()} + onSubmitEditing={() => !canSubmit && doSubmit()} autoCapitalize="none" autoCorrect={false} spellCheck={false}