Open TheProBro opened 3 weeks ago
@cortinico Can you provide the PR that fixes this issue?
@cortinico Can you provide the PR that fixes this issue?
Sorry I picked the wrong label
@TheProBro @cortinico
- Selecting and deleting a word also deletes a space to the left of it, but in this case onSelectionChange fires first
Regarding this issue.
This is the default iOS behaviour. I checked this on system messaging app. Shared recording for reference.
https://github.com/facebook/react-native/assets/85783070/eafffaf0-30e8-423b-9d6a-62b6ee9b9d42
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 return YES
from this function.YES
from this function will further call textViewDidChangeSelection
[UITextField delegate method] with removed one left space character.Solution:
textView(_:shouldChangeTextIn:replacementText:)
method and check if text got changed in textViewDidChangeSelection
then add that extra space. [Here, lots of edge cases needs to handled]For this issue:
For the multiline textinput, for the first keypress onSelectionChange fires first, but for later key presses onChangeText/onChange fire first
I started debugging on this.
@TheProBro. @cortinico Fix for this issue: https://github.com/facebook/react-native/pull/45377
For the multiline textinput, for the first keypress onSelectionChange fires first, but for later key presses onChangeText/onChange fire first
Added my findings in PR itself.
Description
The order remains constant for almost every circumstance: onChange -> onChangeText -> onSelectionChange Here are some cases that i discovered in iOS (could be more)
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
Stacktrace or Logs
Reproducer
https://snack.expo.dev/zhVuXAjkAi5BMHVKq__vG
Screenshots and Videos
No response