diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index 212059986e..7212f611b1 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -65,11 +65,9 @@ export const LoginForm = ({ const [isProcessing, setIsProcessing] = useState(false) const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] = useState(false) - const [isAuthFactorTokenValueEmpty, setIsAuthFactorTokenValueEmpty] = - useState(true) const identifierValueRef = useRef(initialHandle || '') const passwordValueRef = useRef('') - const authFactorTokenValueRef = useRef('') + const [authFactorToken, setAuthFactorToken] = useState('') const identifierRef = useRef(null) const passwordRef = useRef(null) const hasFocusedOnce = useRef(false) @@ -91,7 +89,6 @@ export const LoginForm = ({ const identifier = identifierValueRef.current.toLowerCase().trim() const password = passwordValueRef.current - const authFactorToken = authFactorTokenValueRef.current if (!identifier) { setError(_(msg`Please enter your username`)) @@ -290,24 +287,17 @@ export const LoginForm = ({ autoCorrect={false} autoComplete="one-time-code" returnKeyType="done" - textContentType="username" blurOnSubmit={false} // prevents flickering due to onSubmitEditing going to next field - onChangeText={v => { - setIsAuthFactorTokenValueEmpty(v === '') - authFactorTokenValueRef.current = v - }} + onChangeText={setAuthFactorToken} + value={authFactorToken} // controlled input due to uncontrolled input not receiving pasted values properly onSubmitEditing={onPressNext} editable={!isProcessing} accessibilityHint={_( msg`Input the code which has been emailed to you`, )} - style={[ - { - textTransform: isAuthFactorTokenValueEmpty - ? 'none' - : 'uppercase', - }, - ]} + style={{ + textTransform: authFactorToken === '' ? 'none' : 'uppercase', + }} />