+6
-16
src/screens/Login/LoginForm.tsx
+6
-16
src/screens/Login/LoginForm.tsx
···
65
const [isProcessing, setIsProcessing] = useState<boolean>(false)
66
const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] =
67
useState<boolean>(false)
68
-
const [isAuthFactorTokenValueEmpty, setIsAuthFactorTokenValueEmpty] =
69
-
useState<boolean>(true)
70
const identifierValueRef = useRef<string>(initialHandle || '')
71
const passwordValueRef = useRef<string>('')
72
-
const authFactorTokenValueRef = useRef<string>('')
73
const identifierRef = useRef<TextInput>(null)
74
const passwordRef = useRef<TextInput>(null)
75
const hasFocusedOnce = useRef<boolean>(false)
···
91
92
const identifier = identifierValueRef.current.toLowerCase().trim()
93
const password = passwordValueRef.current
94
-
const authFactorToken = authFactorTokenValueRef.current
95
96
if (!identifier) {
97
setError(_(msg`Please enter your username`))
···
290
autoCorrect={false}
291
autoComplete="one-time-code"
292
returnKeyType="done"
293
-
textContentType="username"
294
blurOnSubmit={false} // prevents flickering due to onSubmitEditing going to next field
295
-
onChangeText={v => {
296
-
setIsAuthFactorTokenValueEmpty(v === '')
297
-
authFactorTokenValueRef.current = v
298
-
}}
299
onSubmitEditing={onPressNext}
300
editable={!isProcessing}
301
accessibilityHint={_(
302
msg`Input the code which has been emailed to you`,
303
)}
304
-
style={[
305
-
{
306
-
textTransform: isAuthFactorTokenValueEmpty
307
-
? 'none'
308
-
: 'uppercase',
309
-
},
310
-
]}
311
/>
312
</TextField.Root>
313
<Text style={[a.text_sm, t.atoms.text_contrast_medium, a.mt_sm]}>
···
65
const [isProcessing, setIsProcessing] = useState<boolean>(false)
66
const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] =
67
useState<boolean>(false)
68
const identifierValueRef = useRef<string>(initialHandle || '')
69
const passwordValueRef = useRef<string>('')
70
+
const [authFactorToken, setAuthFactorToken] = useState('')
71
const identifierRef = useRef<TextInput>(null)
72
const passwordRef = useRef<TextInput>(null)
73
const hasFocusedOnce = useRef<boolean>(false)
···
89
90
const identifier = identifierValueRef.current.toLowerCase().trim()
91
const password = passwordValueRef.current
92
93
if (!identifier) {
94
setError(_(msg`Please enter your username`))
···
287
autoCorrect={false}
288
autoComplete="one-time-code"
289
returnKeyType="done"
290
blurOnSubmit={false} // prevents flickering due to onSubmitEditing going to next field
291
+
onChangeText={setAuthFactorToken}
292
+
value={authFactorToken} // controlled input due to uncontrolled input not receiving pasted values properly
293
onSubmitEditing={onPressNext}
294
editable={!isProcessing}
295
accessibilityHint={_(
296
msg`Input the code which has been emailed to you`,
297
)}
298
+
style={{
299
+
textTransform: authFactorToken === '' ? 'none' : 'uppercase',
300
+
}}
301
/>
302
</TextField.Root>
303
<Text style={[a.text_sm, t.atoms.text_contrast_medium, a.mt_sm]}>