Skip to content

Synchronizing selection of TextInput from onSelectionChange causes cursor to jump #50641

Closed
@z4pf1sh

Description

@z4pf1sh

Description

We're using React Native 0.77.2, and are trying to synchronize onSelectionChange event's data to a React State, bound to TextInput's selection property. With our implementation, when the first letter is typed into the TextInput, the cursor jumps to the beginning of the TextInput. Subsequent inputs are fine without any problem.

Steps to reproduce

  1. Create a new RN project with npx @react-native-community/cli@latest init AwesomeProject --version 0.77.2
  2. Initialize the project normally
  3. Enter ios folder, run pod install, as one normally would
  4. Open AwesomeProject.xcworkspace
  5. Run yarn run start in the root folder to start Metro server
  6. Run the Xcode project, allowing the app to connect to Metro
  7. Select the TextInput widget and type anything into it
  8. Observe the cursor "remaining" at the start of the TextInput

React Native Version

0.77.2

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: macOS 15.1.1
  CPU: (12) arm64 Apple M3 Pro
  Memory: 176.25 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.17.0
    path: ~/.nvm/versions/node/v20.17.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/Library/pnpm/yarn
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v20.17.0/bin/npm
  Watchman:
    version: 2025.03.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/test/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.12816248
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.26
    path: /usr/bin/javac
  Ruby:
    version: 2.7.7
    path: /Users/test/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.2
    wanted: 0.77.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

info React Native v0.79.0 is now available (your project is running on v0.77.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.79.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.77.2&to=0.79.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Stacktrace or Logs

(not available because it is not a crash)

Reproducer

https://github.com/z4pf1sh/repro-rn-textinput

Screenshots and Videos

Screen.Recording.2025-04-11.at.15.48.32.mov

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions