Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (iOS): fix selectTextOnFocus in Fabric and non-Fabric by calling selectAll after becomeFirstResponder #44307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

haileyok
Copy link

@haileyok haileyok commented Apr 29, 2024

Summary:

Fixes #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)

selectTextOnFocus-before.mp4

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.

RocketSim_Recording_iPhone_15_Pro_6.1_2024-04-28_23.42.26.mp4

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 29, 2024
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Apr 29, 2024
@haileyok haileyok changed the title fix (iOS): call selectTextOnFocus after becomeFirstResponder fix (iOS): fix selectTextOnFocus in Fabric and non-Fabric by calling selectAll after becomeFirstResponder Apr 29, 2024
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,461,319 -12
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,834,253 +1
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: bb2c13a
Branch: main

@facebook-github-bot
Copy link
Contributor

@fabriziocucci has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TextInput > iOS > selectTextOnFocus not working as expected
3 participants