'selection' prop is not working in TextInput on Android after React Native upgrade to v0.73 #44171
Labels
Component: TextInput
Related to the TextInput component.
Issue: Author Provided Repro
This issue can be reproduced in Snack or an attached project.
Newer Patch Available
Platform: Android
Android applications.
Type: New Architecture
Issues and PRs related to new architecture (Fabric/Turbo Modules)
Description
Before React Native upgrade, 'selection' prop was used to set the position of the cursor to the specified position. This used to work for readOnly inputs, pre-filled inputs and even for the inputs where the data is being filled.
After the React Native upgrade to v0.73, it is only working for the scenario where the data is being filled and does not work when the TextInput is readOnly or have some pre-filled data.
Our implementation:
We have used state variable to toggle the selection between {start:0} and 'null'. When input is on focus, set the selection to null and when the input is blurred, change the selection to 0. We have implemented this to always show the input data from starting position. ( In Android, by default, this behaviour does not works, and the input shows the data from end ).
Stacktrace or Logs
Reproducer
https://github.com/hariomsinha7/bug-react-native-textinput
Screenshots and Videos
NA
The text was updated successfully, but these errors were encountered: