feat: fix show soft input on focus behavior#35244
Closed
zzz0108 wants to merge 1 commit intofacebook:mainfrom
zzz0108:fix/show-soft-input-on-focus-behavior-ios
Closed
feat: fix show soft input on focus behavior#35244zzz0108 wants to merge 1 commit intofacebook:mainfrom zzz0108:fix/show-soft-input-on-focus-behavior-ios
zzz0108 wants to merge 1 commit intofacebook:mainfrom
zzz0108:fix/show-soft-input-on-focus-behavior-ios
Conversation
Base commit: 6152763 |
Base commit: 6152763 |
|
PR build artifact for 42472db is ready. |
Contributor
|
@jacdebug has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
showSoftInputOnFocusofTextInputis not working properly. When we setshowSoftInputOnFocusto false and subsequently totrue, it fails to open the keyboard, we have to re-focus on the input in order for the keyboard to show. It's expected that the keyboard will be opened as soon asshowSoftInputOnFocusbecomestrue. This happens on iOS only.Reference in React Native doc: https://reactnative.dev/docs/textinput#showsoftinputonfocus.
Changelog
[iOS] [Fixed] - Fix issue where keyboard does not open when
TextInputshowSoftInputOnFocuschanges fromfalsetotrueTest Plan
I've made a clean
create-react-native-apprepo to demonstrate this https://github.com/christianwen/reduced-rn-app.Here's the steps:
yarn installcd ios, thenpod install, thencd ..yarn iosshowSoftInputOnFocusisfalse, 3 seconds later it becomestruedue to asetTimeoutthat is usedScreen.Recording.2022-11-07.at.23.42.11.mov
However, it can be seen that the keyboard does not open even though
showSoftInputOnFocusbecomestrue6. Now add the change in this PR to
Libraries/Text/TextInput/RCTBaseTextInputView.m7. Run
yarn iosagain8. Now verify the step 5 again, the keyboard will open automatically when
showSoftInputOnFocusbecomestrueSimulator.Screen.Recording.-.iPhone.14.-.2022-11-07.at.23.32.01.mp4
The reason why I created a fresh RN repo instead of using
rn-testerapp is because theshowSoftInputOnFocusexample is not working inrn-testerapp for some reasons (it shows the keyboard even thoughshowSoftInputOnFocusisfalsein the example).Regarding the code, it's similar to the fix for
keyboardTypein 8baaacb.