Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ios/EnrichedTextInputView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,7 @@ - (void)handleWordModificationBasedChanges:(NSString *)word
- (void)anyTextMayHaveBeenModified {
// we don't do no text changes when working with iOS marked text
Comment thread
kacperzolkiewski marked this conversation as resolved.
Outdated
if (textView.markedTextRange != nullptr) {
[self handlePlaceholderVisibility];
return;
}

Expand All @@ -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];
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions ios/utils/ParagraphAttributesUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment thread
Copilot marked this conversation as resolved.

// 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) {
Expand Down
Loading