From df80d9c9faa7b3bb270cba6079570eec3ea1b494 Mon Sep 17 00:00:00 2001 From: Rohit <40559587+Rohit3523@users.noreply.github.com> Date: Mon, 5 Oct 2026 23:32:09 +0530 Subject: [PATCH 1/2] fix: two factor keyboard not showing on Android --- .../TextInput/ControlledFormTextInput.tsx | 23 +++++++++++++++++-- app/containers/TwoFactor/index.tsx | 13 ++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/containers/TextInput/ControlledFormTextInput.tsx b/app/containers/TextInput/ControlledFormTextInput.tsx index b7a05e4a0df..df8ee2c3a2d 100644 --- a/app/containers/TextInput/ControlledFormTextInput.tsx +++ b/app/containers/TextInput/ControlledFormTextInput.tsx @@ -1,18 +1,37 @@ +import { type Ref } from 'react'; import { type Control, Controller } from 'react-hook-form'; +import { type TextInput as RNTextInput } from 'react-native'; import { FormTextInput, type IRCTextInputProps } from './FormTextInput'; interface IControlledFormTextInputProps extends Omit { control: Control; name: string; + inputRef?: Ref; } -export const ControlledFormTextInput = ({ control, name, ...props }: IControlledFormTextInputProps) => ( +const setRefValue = (ref: Ref | undefined, value: RNTextInput | null) => { + if (typeof ref === 'function') { + ref(value); + } else if (ref && typeof ref === 'object' && 'current' in ref) { + (ref as { current: RNTextInput | null }).current = value; + } +}; + +export const ControlledFormTextInput = ({ control, name, inputRef, ...props }: IControlledFormTextInputProps) => ( ( - + { + setRefValue(ref, e); + setRefValue(inputRef, e); + }} + {...props} + /> )} /> ); diff --git a/app/containers/TwoFactor/index.tsx b/app/containers/TwoFactor/index.tsx index e8b613b4118..1b6da08ade1 100644 --- a/app/containers/TwoFactor/index.tsx +++ b/app/containers/TwoFactor/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState, memo } from 'react'; -import { AccessibilityInfo, Text, View } from 'react-native'; +import { AccessibilityInfo, Text, View, type TextInput as RNTextInput } from 'react-native'; import isEmpty from 'lodash/isEmpty'; import { sha256 } from 'js-sha256'; import Modal from 'react-native-modal'; @@ -70,6 +70,7 @@ const TwoFactor = memo(() => { const [visible, setVisible] = useState(false); const [data, setData] = useState({}); const pendingCancel = useRef(undefined); + const inputRef = useRef(null); const { control, setValue, @@ -154,13 +155,19 @@ const TwoFactor = memo(() => { }; const color = colors.fontTitlesLabels; + + const handleModalShow = () => { + inputRef.current?.focus(); + }; + return ( } avoidKeyboard useNativeDriver isVisible={visible} - hideModalContentWhileAnimating> + hideModalContentWhileAnimating + onModalShow={handleModalShow}> { Date: Tue, 17 Nov 2026 18:01:55 -0300 Subject: [PATCH 2/2] fix: focus two-factor input with setFocus and keep autoFocus on iOS --- .../TextInput/ControlledFormTextInput.tsx | 23 ++----------------- app/containers/TwoFactor/index.tsx | 14 ++++------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/app/containers/TextInput/ControlledFormTextInput.tsx b/app/containers/TextInput/ControlledFormTextInput.tsx index df8ee2c3a2d..b7a05e4a0df 100644 --- a/app/containers/TextInput/ControlledFormTextInput.tsx +++ b/app/containers/TextInput/ControlledFormTextInput.tsx @@ -1,37 +1,18 @@ -import { type Ref } from 'react'; import { type Control, Controller } from 'react-hook-form'; -import { type TextInput as RNTextInput } from 'react-native'; import { FormTextInput, type IRCTextInputProps } from './FormTextInput'; interface IControlledFormTextInputProps extends Omit { control: Control; name: string; - inputRef?: Ref; } -const setRefValue = (ref: Ref | undefined, value: RNTextInput | null) => { - if (typeof ref === 'function') { - ref(value); - } else if (ref && typeof ref === 'object' && 'current' in ref) { - (ref as { current: RNTextInput | null }).current = value; - } -}; - -export const ControlledFormTextInput = ({ control, name, inputRef, ...props }: IControlledFormTextInputProps) => ( +export const ControlledFormTextInput = ({ control, name, ...props }: IControlledFormTextInputProps) => ( ( - { - setRefValue(ref, e); - setRefValue(inputRef, e); - }} - {...props} - /> + )} /> ); diff --git a/app/containers/TwoFactor/index.tsx b/app/containers/TwoFactor/index.tsx index 1b6da08ade1..1c651da06f0 100644 --- a/app/containers/TwoFactor/index.tsx +++ b/app/containers/TwoFactor/index.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState, memo } from 'react'; -import { AccessibilityInfo, Text, View, type TextInput as RNTextInput } from 'react-native'; +import { AccessibilityInfo, Text, View } from 'react-native'; import isEmpty from 'lodash/isEmpty'; import { sha256 } from 'js-sha256'; import Modal from 'react-native-modal'; @@ -23,6 +23,7 @@ import Toast from '../Toast'; import { showToast } from '~/lib/methods/helpers/showToast'; import log from '~/lib/methods/helpers/log'; import { TWO_FACTOR } from '~/lib/constants/twoFactor'; +import { isAndroid, isIOS } from '~/lib/methods/helpers/deviceInfo'; interface IMethodsProp { text: string; @@ -70,12 +71,12 @@ const TwoFactor = memo(() => { const [visible, setVisible] = useState(false); const [data, setData] = useState({}); const pendingCancel = useRef(undefined); - const inputRef = useRef(null); const { control, setValue, getValues, clearErrors, + setFocus, formState: { errors }, setError } = useForm({ @@ -155,11 +156,6 @@ const TwoFactor = memo(() => { }; const color = colors.fontTitlesLabels; - - const handleModalShow = () => { - inputRef.current?.focus(); - }; - return ( } @@ -167,7 +163,7 @@ const TwoFactor = memo(() => { useNativeDriver isVisible={visible} hideModalContentWhileAnimating - onModalShow={handleModalShow}> + onModalShow={isAndroid ? () => setFocus('code') : undefined}> {