Skip to content

Commit ff70ecf

Browse files
Peter Arganyfacebook-github-bot
authored andcommitted
Fixed <TextInput> bug with autocapitalization
Reviewed By: shergin Differential Revision: D7304936 fbshipit-source-id: ef587db89b64e7111dfdeb049c3a1a334c15430b
1 parent 41db09d commit ff70ecf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,17 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
102102
{
103103
NSInteger eventLag = _nativeEventCount - _mostRecentEventCount;
104104

105-
if (eventLag == 0 && ![attributedText isEqualToAttributedString:self.backedTextInputView.attributedText]) {
105+
// Remove tag attribute to ensure correct attributed string comparison.
106+
NSMutableAttributedString *const backedTextInputViewTextCopy = [self.backedTextInputView.attributedText mutableCopy];
107+
NSMutableAttributedString *const attributedTextCopy = [attributedText mutableCopy];
108+
109+
[backedTextInputViewTextCopy removeAttribute:RCTTextAttributesTagAttributeName
110+
range:NSMakeRange(0, backedTextInputViewTextCopy.length)];
111+
112+
[attributedTextCopy removeAttribute:RCTTextAttributesTagAttributeName
113+
range:NSMakeRange(0, attributedTextCopy.length)];
114+
115+
if (eventLag == 0 && ![attributedTextCopy isEqualToAttributedString:backedTextInputViewTextCopy]) {
106116
UITextRange *selection = self.backedTextInputView.selectedTextRange;
107117
NSInteger oldTextLength = self.backedTextInputView.attributedText.string.length;
108118

0 commit comments

Comments
 (0)