diff --git a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m index 7722f831ad0837..0542362dbe0ac6 100644 --- a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +++ b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m @@ -168,6 +168,8 @@ @interface RCTBackedTextViewDelegateAdapter () @implementation RCTBackedTextViewDelegateAdapter { __weak UITextView *_backedTextInputView; + NSAttributedString *_lastStringStateWasUpdatedWith; + BOOL _ignoreNextTextInputCall; BOOL _textDidChangeIsComing; UITextRange *_previousSelectedTextRange; } @@ -254,12 +256,21 @@ - (BOOL)textView:(__unused UITextView *)textView shouldChangeTextInRange:(NSRang - (void)textViewDidChange:(__unused UITextView *)textView { + if (_ignoreNextTextInputCall && [_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { + _ignoreNextTextInputCall = NO; + return; + } + _lastStringStateWasUpdatedWith = _backedTextInputView.attributedText; _textDidChangeIsComing = NO; [_backedTextInputView.textInputDelegate textInputDidChange]; } - (void)textViewDidChangeSelection:(__unused UITextView *)textView { + if (![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { + [self textViewDidChange:_backedTextInputView]; + _ignoreNextTextInputCall = YES; + } [self textViewProbablyDidChangeSelection]; }