fix android 2fa input not being paste-able (#9407)

This commit is contained in:
Samuel Newman
2025-11-20 17:49:58 +02:00
committed by GitHub
parent f57268e9b8
commit 9823bc98e9
+6 -16
View File
@@ -65,11 +65,9 @@ export const LoginForm = ({
const [isProcessing, setIsProcessing] = useState<boolean>(false) const [isProcessing, setIsProcessing] = useState<boolean>(false)
const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] = const [isAuthFactorTokenNeeded, setIsAuthFactorTokenNeeded] =
useState<boolean>(false) useState<boolean>(false)
const [isAuthFactorTokenValueEmpty, setIsAuthFactorTokenValueEmpty] =
useState<boolean>(true)
const identifierValueRef = useRef<string>(initialHandle || '') const identifierValueRef = useRef<string>(initialHandle || '')
const passwordValueRef = useRef<string>('') const passwordValueRef = useRef<string>('')
const authFactorTokenValueRef = useRef<string>('') const [authFactorToken, setAuthFactorToken] = useState('')
const identifierRef = useRef<TextInput>(null) const identifierRef = useRef<TextInput>(null)
const passwordRef = useRef<TextInput>(null) const passwordRef = useRef<TextInput>(null)
const hasFocusedOnce = useRef<boolean>(false) const hasFocusedOnce = useRef<boolean>(false)
@@ -91,7 +89,6 @@ export const LoginForm = ({
const identifier = identifierValueRef.current.toLowerCase().trim() const identifier = identifierValueRef.current.toLowerCase().trim()
const password = passwordValueRef.current const password = passwordValueRef.current
const authFactorToken = authFactorTokenValueRef.current
if (!identifier) { if (!identifier) {
setError(_(msg`Please enter your username`)) setError(_(msg`Please enter your username`))
@@ -290,24 +287,17 @@ export const LoginForm = ({
autoCorrect={false} autoCorrect={false}
autoComplete="one-time-code" autoComplete="one-time-code"
returnKeyType="done" returnKeyType="done"
textContentType="username"
blurOnSubmit={false} // prevents flickering due to onSubmitEditing going to next field blurOnSubmit={false} // prevents flickering due to onSubmitEditing going to next field
onChangeText={v => { onChangeText={setAuthFactorToken}
setIsAuthFactorTokenValueEmpty(v === '') value={authFactorToken} // controlled input due to uncontrolled input not receiving pasted values properly
authFactorTokenValueRef.current = v
}}
onSubmitEditing={onPressNext} onSubmitEditing={onPressNext}
editable={!isProcessing} editable={!isProcessing}
accessibilityHint={_( accessibilityHint={_(
msg`Input the code which has been emailed to you`, msg`Input the code which has been emailed to you`,
)} )}
style={[ style={{
{ textTransform: authFactorToken === '' ? 'none' : 'uppercase',
textTransform: isAuthFactorTokenValueEmpty }}
? 'none'
: 'uppercase',
},
]}
/> />
</TextField.Root> </TextField.Root>
<Text style={[a.text_sm, t.atoms.text_contrast_medium, a.mt_sm]}> <Text style={[a.text_sm, t.atoms.text_contrast_medium, a.mt_sm]}>