From 8036aff756279529ef63d47f6bbc70d7ed88eadb Mon Sep 17 00:00:00 2001 From: dchersey Date: Thu, 25 Oct 2018 17:05:00 -0400 Subject: [PATCH] Fixing Issue #21243 - capitalized I's when emojiis are present after the text being edited. # Conflicts: # Libraries/Text/TextInput/RCTBaseTextInputView.m --- 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 21af44009184f1..d3f91e0d56fd18 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -105,12 +105,22 @@ - (BOOL)textOf:(NSAttributedString*)newText equals:(NSAttributedString*)oldText{ // Similarly, when the user is in the middle of inputting some text in Japanese/Chinese, there will be styling on the // text that we should disregard. See https://developer.apple.com/documentation/uikit/uitextinput/1614489-markedtextrange?language=objc // for more info. + // Also if user has added an emoji, the sytem adds a font attribute for the emoji and stores the original font in NSOriginalFont. // Lastly, when entering a password, etc., there will be additional styling on the field as the native text view // handles showing the last character for a split second. + __block BOOL fontHasBeenUpdatedBySystem = false; + [oldText enumerateAttribute:@"NSOriginalFont" inRange:NSMakeRange(0, oldText.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { + if (value){ + fontHasBeenUpdatedBySystem = true; + } + }]; + BOOL shouldFallbackToBareTextComparison = [self.backedTextInputView.textInputMode.primaryLanguage isEqualToString:@"dictation"] || self.backedTextInputView.markedTextRange || - self.backedTextInputView.isSecureTextEntry; + self.backedTextInputView.isSecureTextEntry || + fontHasBeenUpdatedBySystem; + if (shouldFallbackToBareTextComparison) { return ([newText.string isEqualToString:oldText.string]); } else {