react-native
react-native copied to clipboard
fix (iOS): fix `selectTextOnFocus` in Fabric and non-Fabric by calling `selectAll` after `becomeFirstResponder`
Summary:
Fixes https://github.com/facebook/react-native/issues/41988
Hopefully even if this isn't the right way to go about solving this, it at least points in the right direction for a different fix!
Currently - both on Paper and Fabric - the selectTextOnFocus prop does not work as expected on a single line text input. It seems that if the UITextField has not yet become the first responder, the text will be briefly selected but then deselected immediately afterward.
This can be seen in the tester when running for either Fabric or Paper (video using Fabric)
https://github.com/facebook/react-native/assets/153161762/aa9c609e-6eb8-4177-a41f-32aae53c06ac
Instead, we can move the selectAll call to reactFocus in RCTBaseTextInputView or focus RCTTextInputComponentView - both of which first call becomeFirstResponder - to get the expected result.
Changelog:
[IOS] [FIXED] - fix selectTextOnFocus in Fabric and non-Fabric by calling selectAll after becomeFirstResponder
Test Plan:
See the rn-tester above prior to these changes. Then test the same against this PR.
https://github.com/facebook/react-native/assets/153161762/8378157c-06e7-424c-a83c-fa71d737dc61
| Platform | Engine | Arch | Size (bytes) | Diff |
|---|---|---|---|---|
| android | hermes | arm64-v8a | 19,626,370 | -817,403 |
| android | hermes | armeabi-v7a | n/a | -- |
| android | hermes | x86 | n/a | -- |
| android | hermes | x86_64 | n/a | -- |
| android | jsc | arm64-v8a | 22,834,253 | -808,216 |
| android | jsc | armeabi-v7a | n/a | -- |
| android | jsc | x86 | n/a | -- |
| android | jsc | x86_64 | n/a | -- |
Base commit: 5df5ed1a88a7119f9837e19169486522e615f93a Branch: main
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@fabriziocucci Is anything blocking getting this in? Did the diff fail internally?
@fabriziocucci Is anything blocking getting this in? Did the diff fail internally?
@gaearon just added a small comment but otherwise LGTM, happy to merge it today.
@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@fabriziocucci merged this pull request in facebook/react-native@cdab5370af7647d00cdf71a5e6134569ce66dc2b.
This pull request was successfully merged by @haileyok in cdab5370af7647d00cdf71a5e6134569ce66dc2b.
When will my fix make it into a release? | How to file a pick request?