From 32b65ea043e0644cbee1db03a315bb0244a5ecda Mon Sep 17 00:00:00 2001 From: Krystian Sienkiewicz Date: Fri, 14 Aug 2026 00:33:13 +0200 Subject: [PATCH 1/3] fix: typing attributes sometimes clearing on keystrokes --- ios/EnrichedTextInputView.mm | 8 ++++++++ ios/inputAttributesManager/InputAttributesManager.h | 1 + ios/inputAttributesManager/InputAttributesManager.mm | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/ios/EnrichedTextInputView.mm b/ios/EnrichedTextInputView.mm index a899aa629..57424b4d5 100644 --- a/ios/EnrichedTextInputView.mm +++ b/ios/EnrichedTextInputView.mm @@ -2000,6 +2000,14 @@ - (bool)textView:(UITextView *)textView return NO; } + // to be sure, we re-run typingAttributes management right before the + // character actually lands. Some times between selection change and the next + // keystroke typing attributes might get removed - seems like a native TextKit + // issue + if (range.length == 0 && text.length > 0) { + [attributesManager repeatRecentTypingAttributesManagement]; + } + return YES; } diff --git a/ios/inputAttributesManager/InputAttributesManager.h b/ios/inputAttributesManager/InputAttributesManager.h index c0cb19df9..b4ba67a7b 100644 --- a/ios/inputAttributesManager/InputAttributesManager.h +++ b/ios/inputAttributesManager/InputAttributesManager.h @@ -13,6 +13,7 @@ - (void)didRemoveTypingAttribute:(NSString *)key; - (void)clearRemovedTypingAttributes; - (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged; +- (void)repeatRecentTypingAttributesManagement; - (void)handleDirtyRangesStyling; - (NSSet *)customAttributesKeys; @end diff --git a/ios/inputAttributesManager/InputAttributesManager.mm b/ios/inputAttributesManager/InputAttributesManager.mm index fc07d871f..b488129d9 100644 --- a/ios/inputAttributesManager/InputAttributesManager.mm +++ b/ios/inputAttributesManager/InputAttributesManager.mm @@ -11,6 +11,7 @@ @implementation InputAttributesManager { NSMutableArray *_dirtyRanges; NSSet *_customAttributesKeys; NSMutableSet *_removedTypingAttributes; + BOOL _recentManagedTypingAttributesOnlySelection; } - (instancetype)initWithInput:(EnrichedTextInputView *)input { @@ -18,6 +19,7 @@ - (instancetype)initWithInput:(EnrichedTextInputView *)input { _input = input; _dirtyRanges = [[NSMutableArray alloc] init]; _removedTypingAttributes = [[NSMutableSet alloc] init]; + _recentManagedTypingAttributesOnlySelection = NO; // setup customAttributes NSMutableSet *_customAttrsSet = [[NSMutableSet alloc] init]; @@ -129,6 +131,7 @@ - (void)handleDirtyRangesStyling { } - (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged { + _recentManagedTypingAttributesOnlySelection = onlySelectionChanged; EnrichedInputTextView *textView = _input->textView; NSRange selectedRange = textView.selectedRange; @@ -219,4 +222,9 @@ - (void)manageTypingAttributesWithOnlySelection:(BOOL)onlySelectionChanged { textView.typingAttributes = newAttrs; } +- (void)repeatRecentTypingAttributesManagement { + [self manageTypingAttributesWithOnlySelection: + _recentManagedTypingAttributesOnlySelection]; +} + @end From 873dca6d3bd081d22f83d455da17fa61af946cc7 Mon Sep 17 00:00:00 2001 From: Krystian Sienkiewicz <146986839+hejsztynx@users.noreply.github.com> Date: Fri, 14 Aug 2026 11:40:14 +0200 Subject: [PATCH 2/3] fix: grammar Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- ios/EnrichedTextInputView.mm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ios/EnrichedTextInputView.mm b/ios/EnrichedTextInputView.mm index 57424b4d5..5810be9d8 100644 --- a/ios/EnrichedTextInputView.mm +++ b/ios/EnrichedTextInputView.mm @@ -2000,10 +2000,9 @@ - (bool)textView:(UITextView *)textView return NO; } - // to be sure, we re-run typingAttributes management right before the - // character actually lands. Some times between selection change and the next - // keystroke typing attributes might get removed - seems like a native TextKit - // issue + // To be sure, we re-run typingAttributes management right before the character + // actually lands. Sometimes, between a selection change and the next keystroke, + // typing attributes might get removed - this seems like a native TextKit issue. if (range.length == 0 && text.length > 0) { [attributesManager repeatRecentTypingAttributesManagement]; } From 0b3ca6911ffe0dd08194002adac197d0368d32bc Mon Sep 17 00:00:00 2001 From: Krystian Sienkiewicz Date: Fri, 14 Aug 2026 12:36:26 +0200 Subject: [PATCH 3/3] fix: lint --- ios/EnrichedTextInputView.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/EnrichedTextInputView.mm b/ios/EnrichedTextInputView.mm index 5810be9d8..ae59b62a6 100644 --- a/ios/EnrichedTextInputView.mm +++ b/ios/EnrichedTextInputView.mm @@ -2000,10 +2000,11 @@ - (bool)textView:(UITextView *)textView return NO; } - // To be sure, we re-run typingAttributes management right before the character - // actually lands. Sometimes, between a selection change and the next keystroke, - // typing attributes might get removed - this seems like a native TextKit issue. - if (range.length == 0 && text.length > 0) { + // To be sure, we re-run typingAttributes management right before the + // character actually lands. Sometimes, between a selection change and the + // next keystroke, typing attributes might get removed - this seems like a + // native TextKit issue. + if (textView.markedTextRange == nil && range.length == 0 && text.length > 0) { [attributesManager repeatRecentTypingAttributesManagement]; }