You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In react-native iOS apps its very common to have a setup where screens are represented as individual UIViewControllers. The most common case is when using:
There is a problem is with transitions between two UIViewController when the new screen contains a <TextInput autoFocus={true} />:
reproducing_input_issue.mov
There are three issues with the transition:
(Not very well visible in the video, but) there is a hang before the screen transition starts
The transition doesn't progress forward all the way. At one point it seems like its slightly reset back, before moving forward again
The keyboard changes its color weirdly from dark to light (i also noticed that's not visible in the video, you can see on the second video below)
Now, your first reaction might be that this is a bug with react-native-screens. It's not, let me explain.
The "problem" is that react-native TextInput implementation calls becomeFirstResponder in didMoveToWindow:
If you try the same in a native iOS app, you can reproduce the issue! I created a sample native iOS app and tried this (the second transition in the recording is actually fine, so this is a bit of a race condition thing it seems):
It seems like this was added back in 2019/2020 to react-native, and back then it seemed to be the correct way to handle the transition correctly (ironically without that code it was causing the same issue i am reporting now)
And in that sense, this seems to me a bit also like an iOS regression. Now, is this a bug we should just delegate to apple to fix in iOS?
I was contemplating about that, and I think it would be good to raise the issue, but at the same time it seems like its not 100% apple's fault.
After some research and talking to some iOS developers they all told me that you'd usually request focus for an input in viewDidAppear, not in didMoveToWindow. In didMoveToWindow we don't know if there is a transition is still in progress, where viewDidAppear seems to be the place we can be absolutely sure our view is present, and the VC fully appeared.
This does change the style of the transition a bit, as you will see the screen transition finish and only then the keyboard appears [but as a pay off it's never buggy]:
viewDidAppear.MP4
I checked all native iOS apps on my phone, including some of apple's, and it seems like all open the keyboard after the VC transition finished. I vaguely recall that when iOS 16 came out people were complaining that apple "broke the keyboard".
I will open the discussion on how we may want to address in the comments below.
Description
In react-native iOS apps its very common to have a setup where screens are represented as individual
UIViewControllers. The most common case is when using:There is a problem is with transitions between two
UIViewControllerwhen the new screen contains a<TextInput autoFocus={true} />:reproducing_input_issue.mov
There are three issues with the transition:
Now, your first reaction might be that this is a bug with react-native-screens. It's not, let me explain.
The "problem" is that react-native TextInput implementation calls
becomeFirstResponderindidMoveToWindow:react-native/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
Lines 120 to 127 in fb0d28c
If you try the same in a native iOS app, you can reproduce the issue! I created a sample native iOS app and tried this (the second transition in the recording is actually fine, so this is a bit of a race condition thing it seems):
ScreenRecording_04-23-2026.13-38-15_1.MP4
It seems like this was added back in 2019/2020 to react-native, and back then it seemed to be the correct way to handle the transition correctly (ironically without that code it was causing the same issue i am reporting now)
And it seems like this was working fine, until iOS 16 came out. Since then new issue reports appeared on react-native-screens about this:
And in that sense, this seems to me a bit also like an iOS regression. Now, is this a bug we should just delegate to apple to fix in iOS?
I was contemplating about that, and I think it would be good to raise the issue, but at the same time it seems like its not 100% apple's fault.
After some research and talking to some iOS developers they all told me that you'd usually request focus for an input in
viewDidAppear, not indidMoveToWindow. IndidMoveToWindowwe don't know if there is a transition is still in progress, whereviewDidAppearseems to be the place we can be absolutely sure our view is present, and the VC fully appeared.This does change the style of the transition a bit, as you will see the screen transition finish and only then the keyboard appears [but as a pay off it's never buggy]:
viewDidAppear.MP4
I checked all native iOS apps on my phone, including some of apple's, and it seems like all open the keyboard after the VC transition finished. I vaguely recall that when iOS 16 came out people were complaining that apple "broke the keyboard".
I will open the discussion on how we may want to address in the comments below.
Steps to reproduce
React Native Version
0.85.2
Affected Platforms
Runtime - iOS
Output of
npx @react-native-community/cli infoStacktrace or Logs
MANDATORY Reproducer
https://github.com/hannojg/ios-textinput-autofocus-transition-uikit-issues
Screenshots and Videos
No response