diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index 65885a4882a686..64a3a865c6d7e7 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -102,7 +102,17 @@ - (void)setAttributedText:(NSAttributedString *)attributedText { NSInteger eventLag = _nativeEventCount - _mostRecentEventCount; - if (eventLag == 0 && ![attributedText isEqualToAttributedString:self.backedTextInputView.attributedText]) { + // Remove tag attribute to ensure correct attributed string comparison. + NSMutableAttributedString *const backedTextInputViewTextCopy = [self.backedTextInputView.attributedText mutableCopy]; + NSMutableAttributedString *const attributedTextCopy = [attributedText mutableCopy]; + + [backedTextInputViewTextCopy removeAttribute:RCTTextAttributesTagAttributeName + range:NSMakeRange(0, backedTextInputViewTextCopy.length)]; + + [attributedTextCopy removeAttribute:RCTTextAttributesTagAttributeName + range:NSMakeRange(0, attributedTextCopy.length)]; + + if (eventLag == 0 && ![attributedTextCopy isEqualToAttributedString:backedTextInputViewTextCopy]) { UITextRange *selection = self.backedTextInputView.selectedTextRange; NSInteger oldTextLength = self.backedTextInputView.attributedText.string.length;