Skip to content

Commit

Permalink
Fixed <TextInput> bug with autocapitalization
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D7304936

fbshipit-source-id: ef587db89b64e7111dfdeb049c3a1a334c15430b
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Mar 19, 2018
1 parent 41db09d commit ff70ecf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ff70ecf

Please sign in to comment.