-
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
Fix autocorrect onChangeText firing (#22691) #23666
Conversation
fixes #22691 |
Would appreciate some extra eyes on this, it appears to work, though. |
cc @rigdern, @mandrigin That's really cool. I didn't know that the API that we use here exists! That also probably can help us to fix other Korean/Japanese/Chinese issues. I will test it and hopefully land soon. |
didProcessEditing:(__unused NSTextStorageEditActions)editedMask | ||
range:(__unused NSRange)editedRange | ||
changeInLength:(__unused NSInteger)delta { | ||
[_backedTextInputView.textInputDelegate textInputDidChange]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried a bit about over-firing. So, e.g. if only text attributes were changed, we don't want to send an event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check if this is the case & fix it if that does occur.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This reverts commit 9bfa4fa.
@shergin I changed this PR- I originally removed code from the UITextField adapter implementation, this was a mistake I believe. So, listening to the NSTextStorage only applies to multiline TextInput components. I feel like it would make sense for us to use UITextView instead of UITextField for all TextInput's due to UITextView having lower level API access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give some my opinions:
- textStorage:didProcessEditing:range:changeInLength:
delegate would not be called, we should settextStorage.delegate
to adapter.textStorage
is created and managed byUITextView
, so is it really safe to change the delegate?- textStorage:didProcessEditing:range:changeInLength:
would be called when text attributes changed, I think it may not what we want.- textStorage:didProcessEditing:range:changeInLength:
would always be called, for example, we setdefaultValue
props for initial value, it should't be calledonChange
.- If all things above fixes, singleline textinput still has issues. Because this
PR
try to fix multiline textinput.
@zhongwuzw ah yes, I forgot to set the delegate in my cleaned up version. I will fix that. Good point on the remaining issues. |
Summary
This fixes an issue where autocorrect changes may cause
onChangeText
to not fire. It subscribes to the underlyingtextStorage
of the UITextView. It is possible this fixes a few other issues, due to the nature of listening to the underlying textStorage changes.Changelog
[iOS] [Fixed] - iOS firing onChangeText when choosing autocorrect options
Test Plan
Open RNTester, and interact with textfields.