Skip to content

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

@larskarbo

Description

@larskarbo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: TextInputRelated to the TextInput component.Platform: iOSiOS applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions