diff --git a/ios/EnrichedTextInputView.mm b/ios/EnrichedTextInputView.mm index 8795f0bbb..94ce793be 100644 --- a/ios/EnrichedTextInputView.mm +++ b/ios/EnrichedTextInputView.mm @@ -1662,8 +1662,9 @@ - (void)handleWordModificationBasedChanges:(NSString *)word } - (void)anyTextMayHaveBeenModified { - // we don't do no text changes when working with iOS marked text + // we don't do text changes when working with iOS marked text if (textView.markedTextRange != nullptr) { + [self handlePlaceholderVisibility]; return; } @@ -1685,13 +1686,7 @@ - (void)anyTextMayHaveBeenModified { [mentionStyleClass manageMentionEditing]; } - // placholder management - if (!_placeholderLabel.hidden && textView.textStorage.string.length > 0) { - [self setPlaceholderLabelShown:NO]; - } else if (textView.textStorage.string.length == 0 && - _placeholderLabel.hidden) { - [self setPlaceholderLabelShown:YES]; - } + [self handlePlaceholderVisibility]; // modified words handling NSArray *currentDirtyRanges = [attributesManager getDirtyRanges]; @@ -1747,6 +1742,16 @@ - (void)anyTextMayHaveBeenModified { [self scheduleRelayoutIfNeeded]; } +- (void)handlePlaceholderVisibility { + // placeholder management + if (!_placeholderLabel.hidden && textView.textStorage.string.length > 0) { + [self setPlaceholderLabelShown:NO]; + } else if (textView.textStorage.string.length == 0 && + _placeholderLabel.hidden) { + [self setPlaceholderLabelShown:YES]; + } +} + // Debounced relayout helper - coalesces multiple requests into one per runloop // tick - (void)scheduleRelayoutIfNeeded { diff --git a/ios/utils/ParagraphAttributesUtils.mm b/ios/utils/ParagraphAttributesUtils.mm index 517e5b349..0a70351f9 100644 --- a/ios/utils/ParagraphAttributesUtils.mm +++ b/ios/utils/ParagraphAttributesUtils.mm @@ -20,6 +20,13 @@ + (BOOL)handleBackspaceInRange:(NSRange)range return NO; } + // Do not manually intervene if the user is in the middle of IME + // composition. Let the iOS system handle the backspace natively to prevent + // state desync. + if (typedInput->textView.markedTextRange != nullptr) { + return NO; + } + // we make sure it was a backspace (text with 0 length) and it deleted // something (range longer than 0) if (text.length > 0 || range.length == 0) {