From 5cdf42b9f7879ae32203d21f05bda33e3466adc6 Mon Sep 17 00:00:00 2001 From: Stephanie Freitag <stephanie.freitag@holi.team> Date: Wed, 29 Jan 2025 10:46:32 +0100 Subject: [PATCH] HOLI-10883: prevent autofocus on account creation screen --- core/auth/components/FormBuilder.tsx | 4 +++- core/screens/onboarding/steps/CreateAccount.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/auth/components/FormBuilder.tsx b/core/auth/components/FormBuilder.tsx index 7a732beb32..f48d491bf4 100644 --- a/core/auth/components/FormBuilder.tsx +++ b/core/auth/components/FormBuilder.tsx @@ -33,6 +33,7 @@ interface Props<T> { textInputOverride?: TextInputOverride scrollToInputWithId?: (id: string) => ScrollToProps autofocusField?: NodeId + noAutofocusForEmail?: boolean translationPrefix?: string style?: ViewStyle | ViewStyle[] | Record<string, unknown> } @@ -53,6 +54,7 @@ const FormBuilder = < textInputOverride, scrollToInputWithId, autofocusField, + noAutofocusForEmail = false, translationPrefix = 'auth.login.', style, }: Props<T>) => { @@ -68,7 +70,7 @@ const FormBuilder = < const isEmailField = (name: string) => name === 'identifier' || name === 'traits.email' || name === 'email' const hasAutofocus = (node: UiNode) => { const name = getNodeId(node) - const hasFocus = autofocusField === name || isEmailField(name) + const hasFocus = autofocusField === name || (!noAutofocusForEmail && isEmailField(name)) return hasFocus && !(node.attributes as UiNodeInputAttributes).disabled } diff --git a/core/screens/onboarding/steps/CreateAccount.tsx b/core/screens/onboarding/steps/CreateAccount.tsx index 71839d40b4..aaaddaf798 100644 --- a/core/screens/onboarding/steps/CreateAccount.tsx +++ b/core/screens/onboarding/steps/CreateAccount.tsx @@ -149,7 +149,7 @@ export const CreateAccount = ({ </Text> <HoliGap size="xs" /> <Text size="md">{t('registration.signUp.description')}</Text> - <FormBuilder flow={flow} onSubmit={onSubmit} style={styles.loginForm} /> + <FormBuilder flow={flow} onSubmit={onSubmit} style={styles.loginForm} noAutofocusForEmail /> <HoliGap size="s" /> <ButtonTracked label={t('auth.loginProtection.continueAsGuest')} -- GitLab