question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[0.54] [iOS] Selection jumps to end of TextInput on every change

See original GitHub issue

On 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.

bug

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:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
jeffreybrowningcommented, Feb 13, 2020

I unfortunately do not have the power to reopen. Only commenting for 👀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cursor jumps to end of controlled input · Issue #955 - GitHub
When an input element is "controlled" by a model, the cursor will jump to the end of the line on every change. This...
Read more >
Cursor jumps to end of field - Apple Community
Touch and hold the Space bar with one finger until the keyboard turns light gray. Move the insertion point by dragging around the...
Read more >
React controlled input cursor jumps - Stack Overflow
If your value is controlled by state, React will maintain the input's cursor position. The problem is when the input receives a change...
Read more >
TextInput - React Native Archive
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto-correction, ...
Read more >
Solving Caret Jumping in React Inputs - DEV Community ‍ ‍
The problem we faced is that it also jumps when the value hasn't changed at all, except for the new character just typed....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found