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

[iOS] Fix selecting search input on focus #3746

Merged
merged 2 commits into from
Apr 28, 2024
Merged

[iOS] Fix selecting search input on focus #3746

merged 2 commits into from
Apr 28, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Apr 28, 2024

Makes this work on iOS.

search.mov

Doesn't touch Android or web.

Copy link

render bot commented Apr 28, 2024

if (isIOS) {
// We rely on selectTextOnFocus, but it's broken on iOS:
// https://github.com/facebook/react-native/issues/41988
textInput.current?.setSelection(0, searchText.length)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not ideal that we rely on searchText.length here. I think in theory it could be stale. I haven't been able to trigger that tho. Seems fine.

Copy link

Old size New size Diff
6.44 MB 6.44 MB 62 B (0.00%)

Copy link
Contributor

@haileyok haileyok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that it works on both Android and iOS now. I might spend 30 minutes looking at the code here to see what it's supposed to be doing, been working on another PR for TextInput anyway.

@gaearon gaearon merged commit dfce190 into main Apr 28, 2024
6 checks passed
@gaearon gaearon deleted the fix-input-focus branch April 28, 2024 21:52
@Emmaccen
Copy link

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants