From be2226d079defa516ceb8e7b8df140d17c334143 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 10 Nov 2025 19:05:09 +0200 Subject: [PATCH] highlight error field --- src/screens/Login/LoginForm.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index 8a28771178..c12bb294a8 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -57,9 +57,11 @@ export const LoginForm = ({ onAttemptFailed: () => void }) => { const t = useTheme() - const [isProcessing, setIsProcessing] = useState(false) - const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] = - useState(false) + const [isProcessing, setIsProcessing] = useState(false) + const [errorField, setErrorField] = useState< + 'none' | 'identifier' | 'password' | '2fa' + >('none') + const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] = useState(false) const identifierValueRef = useRef(initialHandle || '') const passwordValueRef = useRef('') const [authFactorToken, setAuthFactorToken] = useState('') @@ -80,17 +82,20 @@ export const LoginForm = ({ if (isProcessing) return Keyboard.dismiss() setError('') + setErrorField('none') const identifier = identifierValueRef.current.toLowerCase().trim() const password = passwordValueRef.current if (!identifier) { setError(_(msg`Please enter your username`)) + setErrorField('identifier') return } if (!password) { setError(_(msg`Please enter your password`)) + setErrorField('password') return } @@ -147,6 +152,7 @@ export const LoginForm = ({ error: errMsg, }) setError(_(msg`Invalid 2FA confirmation code.`)) + setErrorField('2fa') } else if ( errMsg.includes('Authentication Required') || errMsg.includes('Invalid identifier or password') @@ -187,7 +193,7 @@ export const LoginForm = ({ Account - + { identifierValueRef.current = v + if (errorField) setErrorField('none') }} onSubmitEditing={() => { passwordRef.current?.focus() @@ -214,7 +221,7 @@ export const LoginForm = ({ /> - + { passwordValueRef.current = v + if (errorField) setErrorField('none') }} onSubmitEditing={onPressNext} blurOnSubmit={false} // HACK: https://github.com/facebook/react-native/issues/21911#issuecomment-558343069 Keyboard blur behavior is now handled in onSubmitEditing @@ -270,7 +278,7 @@ export const LoginForm = ({ 2FA Confirmation - + { + setAuthFactorToken(text) + if (errorField) setErrorField('none') + }} onSubmitEditing={onPressNext} editable={!isProcessing} accessibilityHint={_(