Skip to content

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

Closed

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

Activity

  1. maxlxq commented on Mar 13, 2018

    @maxlxq

    me too

  2. added
    Platform: iOS
    on Mar 13, 2018
  3. added
    Ran Commands
    Component: TextInput
    Platform: macOS
    on Mar 16, 2018
  4. akalin-keybase commented on Mar 27, 2018

    @akalin-keybase

    I think this happens only for multiline TextInputs.

  5. removed
    Platform: macOS
    on Mar 29, 2018
  6. vrgimael commented on Apr 29, 2018

    @vrgimael

    This seems to be causing other glitches, especially regarding how auto-correct detects changes.

    It only happens on multiline indeed.

    Any updates on the issue?

  7. vrgimael commented on Apr 29, 2018

    @vrgimael

    Update - this solved my problems:

    ff70ecf#diff-a5239f085f0beab82ba2c1643be157ac

  8. matthieubessol commented on May 21, 2018

    @matthieubessol

    I am also getting this. I'm on react-native v0.55.4. When I hit return two times and returning back to my previous text, letters are capitalized every time. Your code did fix the problem, but it would be nice if they fix it.

  9. stale commented on Aug 19, 2018

    @stale

    Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

  10. added
    Stale
    on Aug 19, 2018
  11. akalin-keybase commented on Aug 20, 2018

    @akalin-keybase

    this is still broken, afaik

  12. removed
    Stale
    on Aug 20, 2018
  13. 1 remaining item

  14. added
    Stale
    on Dec 21, 2018
  15. akalin-keybase commented on Dec 21, 2018

    @akalin-keybase

    this is still broken, afaik

  16. removed
    Stale
    on Dec 21, 2018
  17. thymikee commented on Mar 19, 2019

    @thymikee
    Contributor

    Closing, because there's no recent activity under the issue.

    @akalin-keybase if it still doesn't work for you, please create a new issue with a minimal reproduction we can investigate.

  18. jeffreybrowning commented on Jul 29, 2019

    @jeffreybrowning

    If #18341 (comment) did fix, this remains an issue for Expo users as SDK 33 uses react-native 0.59

  19. mistikk commented on Oct 25, 2019

    @mistikk

    Same issue on rn 0.61.2, please reopen to this issue @thymikee @jeffreybrowning

  20. nguyen95 commented on Nov 23, 2019

    @nguyen95

    Me too, this happened on ios, rn 0.61.3

  21. jeffreybrowning commented on Feb 13, 2020

    @jeffreybrowning

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

  22. locked as resolved and limited conversation to collaborators on Mar 19, 2020
  23. added
    Resolution: Locked
    on Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: TextInputPlatform: iOSRan CommandsResolution: Locked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions