Skip to content

Commit

Permalink
fix(auth): MB-2996, fixing unwanted submit on first name input
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisTouchardEdifice committed Dec 2, 2024
1 parent ba519f0 commit 129b587
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/framework/modules/auth/templates/forgot/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ export const ForgotPage: React.FC<ForgotScreenPrivateProps> = (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
Expand Down Expand Up @@ -138,7 +141,7 @@ export const ForgotPage: React.FC<ForgotScreenPrivateProps> = (props: ForgotScre
editable={!hasStructures}
returnKeyLabel={I18n.get('auth-forgot-submit')}
returnKeyType="done"
onSubmitEditing={() => doSubmit()}
onSubmitEditing={() => !canSubmit && doSubmit()}
autoCapitalize="none"
autoCorrect={false}
spellCheck={false}
Expand Down

0 comments on commit 129b587

Please sign in to comment.