Open QichenZhu opened 7 hours ago
@QichenZhu Is this happening only on Android? Did you get a chance to check on iOS?
@shubhamguptadream11 It works fine on iOS.
https://github.com/user-attachments/assets/0802560c-ca6f-4057-b5d1-d96ec012c59d
In my testing, the selection changed after this line.
A possible fix is to save and restore the selection before and after it.
int prevSelectionStart = getSelectionStart();
int prevSelectionEnd = getSelectionEnd();
super.setTextIsSelectable(true);
setSelection(prevSelectionStart, prevSelectionEnd);
I can create a PR if you're interested.
Yeah sure go ahead!
Description
Create a
TextInput
component withvalue
andselection
attributes, then programmatically focus it after a delay. You'll find the caret at the beginning instead of at the specified selection.This is only reproducible under the New Arch.
Steps to reproduce
Build the app with New Arch enabled and run it on Android.
Wait a second.
Expected result: The caret is at the end.
Actual result: The caret is at the beginning.
React Native Version
0.75.4
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/QichenZhu/reproducer-react-native-textinput.git
Screenshots and Videos
https://github.com/user-attachments/assets/b0e2f80d-f76d-4c32-b410-3c460aed404b