From ff70ecf868cf12fc66b45dc1496391d0a1e9011f Mon Sep 17 00:00:00 2001 From: Peter Argany Date: Mon, 19 Mar 2018 14:09:32 -0700 Subject: [PATCH] Fixed bug with autocapitalization Reviewed By: shergin Differential Revision: D7304936 fbshipit-source-id: ef587db89b64e7111dfdeb049c3a1a334c15430b --- Libraries/Text/TextInput/RCTBaseTextInputView.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;