Skip to content

Changing TextInput selection after setting text crash #25265

Closed
fabOnReact/react-native-improved
#16

Description

@Vaintti

When TextInput selection is updated after changing the text (using InteractionManager.runAfterInteractions to wait for the change to apply) RN crashes. You get error like "setSpan(4 ... 4) ends beyond length" which indicates that the text field text has not changed like you would expect when using runAfterInteractions.
React Native version:

info
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 34.23 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 24, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
System Images: android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9

Steps To Reproduce

  1. Change controlled TextInput value in code
  2. Change TextInput selection to be after the inserted text using InteractionManager.runAfterInteractions

or just run the example in repo I linked and press the button.

Describe what you expected to happen:
Selection changes to place after inserted text

Snack, code example, or link to a repository:
https://github.com/Vaintti/RNTextInputBug

Activity

  1. added
    Component: TextInput
    on Jun 14, 2019
  2. blohamen commented on Aug 13, 2019

    @blohamen

    Have similar issue on RN 0.60.4

  3. blohamen commented on Oct 4, 2019

    @blohamen

    Issue still reproduced in React Native 0.61.2

  4. callcter commented on Oct 16, 2019

    @callcter

    same issue in 0.61.2

  5. cayodonatti commented on Nov 26, 2019

    @cayodonatti

    I also still got the issue in React Native 0.61.1, seems to only happen on Android

  6. anilios commented on Nov 28, 2019

    @anilios

    I am also having same issue.. don't know how to fix..

    Screenshot_20191128-131822_Good Neighbour

  7. stale commented on Feb 27, 2020

    @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 a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

  8. added
    Stale
    on Feb 27, 2020
  9. jsamr commented on Feb 27, 2020

    @jsamr

    This issue has not been fixed.

  10. removed
    Stale
    on Feb 27, 2020
  11. 7 remaining items

  12. jsamr commented on Aug 29, 2020

    @jsamr

    Someone has been able to reproduce on latest versions?

  13. removed
    Stale
    on Aug 29, 2020
  14. stale commented on Dec 25, 2020

    @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 a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

  15. added
    Stale
    on Dec 25, 2020
  16. jsamr commented on Dec 26, 2020

    @jsamr

    I believe this is still relevant.

  17. removed
    Stale
    on Dec 26, 2020
  18. SonuToor commented on Jan 26, 2021

    @SonuToor

    Still having this on 0.63.3

  19. jsamr commented on Feb 26, 2021

    @jsamr

    I just reproduced this bug on 0.63.4

  20. fabOnReact commented on Mar 16, 2021

    @fabOnReact
    Contributor

    Please, is it possible to merge this PR in the next version ?

    To answer the question of when the pr #29070 which fixes this issue will be released in the next version of React Native, I suggest you to follow the discussions at https://github.com/react-native-community/releases/issues by subscribing to those threads. The process of releasing a new version with a bug fix is the following:

  21. github-actions commented on Mar 12, 2023

    @github-actions

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  22. added
    Stale
    on Mar 12, 2023
  23. github-actions commented on Mar 19, 2023

    @github-actions

    This issue was closed because it has been stalled for 7 days with no activity.

  24. locked as resolved and limited conversation to collaborators on Mar 20, 2023
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: TextInputStale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions