Skip to content

Commit f307ac7

Browse files
dcherseyfacebook-github-bot
authored andcommitted
Fixes capitalized I's when emojiis are present after the text being edited. (#21951)
Summary: Fixes #21243. Fixes #20908. Credit goes to superandrew213 who provided the patch based on 0.56; this commit merges and resolved the conflict introduced in 0.57. Pull Request resolved: #21951 Differential Revision: D13980799 Pulled By: cpojer fbshipit-source-id: 6b9f1a1ae54ad9dba043005d683d6a221472c729
1 parent 9842e39 commit f307ac7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

+11-1
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,22 @@ - (BOOL)textOf:(NSAttributedString*)newText equals:(NSAttributedString*)oldText{
105105
// Similarly, when the user is in the middle of inputting some text in Japanese/Chinese, there will be styling on the
106106
// text that we should disregard. See https://developer.apple.com/documentation/uikit/uitextinput/1614489-markedtextrange?language=objc
107107
// for more info.
108+
// If the user added an emoji, the sytem adds a font attribute for the emoji and stores the original font in NSOriginalFont.
108109
// Lastly, when entering a password, etc., there will be additional styling on the field as the native text view
109110
// handles showing the last character for a split second.
111+
__block BOOL fontHasBeenUpdatedBySystem = false;
112+
[oldText enumerateAttribute:@"NSOriginalFont" inRange:NSMakeRange(0, oldText.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) {
113+
if (value){
114+
fontHasBeenUpdatedBySystem = true;
115+
}
116+
}];
117+
110118
BOOL shouldFallbackToBareTextComparison =
111119
[self.backedTextInputView.textInputMode.primaryLanguage isEqualToString:@"dictation"] ||
112120
self.backedTextInputView.markedTextRange ||
113-
self.backedTextInputView.isSecureTextEntry;
121+
self.backedTextInputView.isSecureTextEntry ||
122+
fontHasBeenUpdatedBySystem;
123+
114124
if (shouldFallbackToBareTextComparison) {
115125
return ([newText.string isEqualToString:oldText.string]);
116126
} else {

0 commit comments

Comments
 (0)