Repository navigation
Open
Labels
Component: TextInputRelated to the TextInput component.Related to the TextInput component.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.
Description
Description
The order remains constant for almost every circumstance:
onChange -> onChangeText -> onSelectionChange
Here are some cases that i discovered in iOS (could be more)
- For the multiline textinput, for the first keypress onSelectionChange fires first, but for later key presses onChangeText/onChange fire first
- Selecting and deleting a word also deletes a space to the left of it, but in this case onSelectionChange fires first
Steps to reproduce
Snack
In textInput component, use multiline and console.log as callbacks for each of the functions in discussion, see the output
React Native Version
0.74.84
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 14.5
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 33.76 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 21.7.3
path: ~/.nvm/versions/node/v21.7.3/bin/node
Yarn: Not Found
npm:
version: 10.5.0
path: ~/.nvm/versions/node/v21.7.3/bin/npm
Watchman:
version: 2024.05.06.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK: Not Found
IDEs:
Android Studio: 2023.2 AI-232.10300.40.2321.11668458
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 20.0.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.2
wanted: 0.74.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
selection triggered {"end":1,"start":1}
change triggered
change text triggered H
change triggered
change text triggered i
selection triggered {"end":1,"start":1}
Reproducer
https://snack.expo.dev/zhVuXAjkAi5BMHVKq__vG
Screenshots and Videos
No response
Reacted by Dean
Metadata
Metadata
Assignees
Labels
Component: TextInputRelated to the TextInput component.Related to the TextInput component.Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.
Activity
TheProBro commentedon Jun 18, 2024
@cortinico Can you provide the PR that fixes this issue?
cortinico commentedon Jun 18, 2024
Sorry I picked the wrong label
shubhamguptadream11 commentedon Jul 10, 2024
@TheProBro @cortinico
Regarding this issue.
This is the default iOS behaviour.
I checked this on system messaging app. Shared recording for reference.
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-07-10.at.15.55.35.mp4
Findings:
textView(_:shouldChangeTextIn:replacementText:)[UITextField delegate method] will be called first when we press backspace on keyboard with replacement string "". This will detect that text on Edit Text to be changed(Not reflected yet) and returnYESfrom this function.YESfrom this function will further calltextViewDidChangeSelection[UITextField delegate method] with removed one left space character.Solution:
textView(_:shouldChangeTextIn:replacementText:)method and check if text got changed intextViewDidChangeSelectionthen add that extra space. [Here, lots of edge cases needs to handled]For this issue:
I started debugging on this.
shubhamguptadream11 commentedon Jul 11, 2024
@TheProBro. @cortinico
Fix for this issue: #45377
Added my findings in PR itself.
SeekingLight233 commentedon May 13, 2025
Are there any updates on this issue? It still persists in React Native v0.78 with the old architecture disabled