[0.54] [iOS] Selection jumps to end of TextInput on every change
See original GitHub issueOn version 0.54.2
on iOS
When typing in a TextInput
with a controlled value
prop, multiple onSelectionChange
events fires.
You don’t always see the flickering when rendering, but this can cause problems if you have a very long TextInput
or use the selection
prop in other ways.
Environment
Environment: OS: macOS High Sierra 10.13.3 Node: 9.8.0 Yarn: 1.5.1 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: ^16.3.0-alpha.1 => 16.3.0-alpha.1 react-native: 0.54.2 => 0.54.2
Expected Behavior
One onSelectionChange
event is fired and cursor doesn’t jump to end and back.
Actual Behavior
For every keystroke there is one instant correct event, then the new value goes through setState
and renders down into the value
prop again. This causes two more events: one where selection is at end of the string, followed by one correct event.
Steps to Reproduce
The code I used to test is in this snack: https://snack.expo.io/HJaZucVYf
Use that code with v0.54.2
to reproduce
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:14 (1 by maintainers)
Update - this solved my problems:
https://github.com/facebook/react-native/commit/ff70ecf868cf12fc66b45dc1496391d0a1e9011f#diff-a5239f085f0beab82ba2c1643be157ac
I unfortunately do not have the power to reopen. Only commenting for 👀