-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Incosistent behavior on setting selection using TextInput setNativeProps #34695
Comments
+1 |
` ` |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Any updates from the maintainer? |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
I also encountered this problem in 0.67. My current temporary solution is to use the following code: this.textInputRef.setNativeProps({
selection: {
start: this.innerValue?.length || 0,
end: this.innerValue?.length || 0,
},
})
if (Platform.OS === "android") {
setTimeout(() => {
this.textInputRef.setNativeProps({
selection: null,
})
})
} This problem seems to have existed for a long time. setNativeProps looks imperative on iOS, but behaves differently on Android. |
Description
I want to move the cursor to the end of the input when it gets focus, so I use
setNativeProps
:However, the input behaves differently on Android and iOS. On iOS, the cursor jumps to the end as expected and inputting text works. On Android, though the cursor jumps to the end, it "locks" to that position on inputting text (see the video attached below).
I try to use
-1
instead oftext.length
. In this case, the Android works but on iOS the cursor jumps to the start instead of the end.It looks like a Android specific bug.
Version
0.70.0
Output of
npx react-native info
Steps to reproduce
Snack, code example, screenshot, or link to a repository
The full project demostrating this issue in here: https://github.com/perqin/NativePropsSelectionIssue.
The video on Android:
1_1663226606.mp4
The text was updated successfully, but these errors were encountered: