-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextInput onSelectionChange() is fired before onChangeText() in IOS, and fired after onChangeText() in Android when letter typed #28865
Comments
|
I've just come across this issue as well
|
same issue! System: |
Same issue here! |
Same issue here, working on a project that needs mentions and this is tripping us up too. |
This isn't a perfect solution but we ended up calculating the current selection in the onChangeText callback. If it was IOS we could just use the current selection passed back from onSelectionChange (stored in a ref), and if it was android we would add / subtract the difference in length between the updated and previous value from the selection ref start and end values...there is some nuances for multi char removal etc. but that was the general idea |
Have you already resolved this?
I'm stucking on this in same situation, my mention tracking doesn't work for this issue.... |
Summary: Switched order of onSelectionChange and onChange events on iOS This was already fixed but for fabric only https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L36-L46 This PR is a complementary of 7b48899 Fixes #28865 ## Changelog [IOS] [FIXED] - onSelectionChange() is fired before onChange() on multiline TextInput Pull Request resolved: #35603 Test Plan: Reproduce the minimal example provided here #28865 Verify that the events order is onChange then onSelectionChange with no duplicates Reviewed By: cipolleschi Differential Revision: D41947673 Pulled By: dmytrorykun fbshipit-source-id: cf452a6101400b1b54295c83fa7735449d91e781
…k#35603) Summary: Switched order of onSelectionChange and onChange events on iOS This was already fixed but for fabric only https://github.com/facebook/react-native/blob/main/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L36-L46 This PR is a complementary of facebook@7b48899 Fixes facebook#28865 ## Changelog [IOS] [FIXED] - onSelectionChange() is fired before onChange() on multiline TextInput Pull Request resolved: facebook#35603 Test Plan: Reproduce the minimal example provided here facebook#28865 Verify that the events order is onChange then onSelectionChange with no duplicates Reviewed By: cipolleschi Differential Revision: D41947673 Pulled By: dmytrorykun fbshipit-source-id: cf452a6101400b1b54295c83fa7735449d91e781
same issues here, any solutions? |
Description
TextInput
onSelectionChange()
is fired beforeonChangeText()
in IOS, and fired after onChangeText() in Android when letter is typedReact Native Environment Info
System
Binaries
SDK sdk-35.0.0
Steps To Reproduce
IOS
Android
Expected Results
In the same order
The text was updated successfully, but these errors were encountered: