Skip to content
Permalink
Browse files

Fixed <TextInput> bug with autocapitalization

Reviewed By: shergin

Differential Revision: D7304936

fbshipit-source-id: ef587db89b64e7111dfdeb049c3a1a334c15430b
  • Loading branch information...
PeteTheHeat authored and facebook-github-bot committed Mar 19, 2018
1 parent 41db09d commit ff70ecf868cf12fc66b45dc1496391d0a1e9011f
Showing with 11 additions and 1 deletion.
  1. +11 −1 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;

0 comments on commit ff70ecf

Please sign in to comment.
You can’t perform that action at this time.