Skip to content

Commit c1f5fb6

Browse files
fix(iOS): removing chars during IME composition (#674)
# Summary Fixes: #673 ## Test Plan Run reproduction steps from #673 the issue should be resolved. ## Screenshots / Videos https://github.com/user-attachments/assets/b41de743-0652-4d2d-bd8a-62db9c403f8e ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ | | Web | ❌ | ## Checklist - [X] E2E tests are passing - [ ] Required E2E tests have been added (if applicable) --------- Co-authored-by: Mikołaj Szydłowski <9szydlowski9@gmail.com>
1 parent 120206f commit c1f5fb6

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

ios/EnrichedTextInputView.mm

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,9 @@ - (void)handleWordModificationBasedChanges:(NSString *)word
16621662
}
16631663

16641664
- (void)anyTextMayHaveBeenModified {
1665-
// we don't do no text changes when working with iOS marked text
1665+
// we don't do text changes when working with iOS marked text
16661666
if (textView.markedTextRange != nullptr) {
1667+
[self handlePlaceholderVisibility];
16671668
return;
16681669
}
16691670

@@ -1685,13 +1686,7 @@ - (void)anyTextMayHaveBeenModified {
16851686
[mentionStyleClass manageMentionEditing];
16861687
}
16871688

1688-
// placholder management
1689-
if (!_placeholderLabel.hidden && textView.textStorage.string.length > 0) {
1690-
[self setPlaceholderLabelShown:NO];
1691-
} else if (textView.textStorage.string.length == 0 &&
1692-
_placeholderLabel.hidden) {
1693-
[self setPlaceholderLabelShown:YES];
1694-
}
1689+
[self handlePlaceholderVisibility];
16951690

16961691
// modified words handling
16971692
NSArray *currentDirtyRanges = [attributesManager getDirtyRanges];
@@ -1747,6 +1742,16 @@ - (void)anyTextMayHaveBeenModified {
17471742
[self scheduleRelayoutIfNeeded];
17481743
}
17491744

1745+
- (void)handlePlaceholderVisibility {
1746+
// placeholder management
1747+
if (!_placeholderLabel.hidden && textView.textStorage.string.length > 0) {
1748+
[self setPlaceholderLabelShown:NO];
1749+
} else if (textView.textStorage.string.length == 0 &&
1750+
_placeholderLabel.hidden) {
1751+
[self setPlaceholderLabelShown:YES];
1752+
}
1753+
}
1754+
17501755
// Debounced relayout helper - coalesces multiple requests into one per runloop
17511756
// tick
17521757
- (void)scheduleRelayoutIfNeeded {

ios/utils/ParagraphAttributesUtils.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ + (BOOL)handleBackspaceInRange:(NSRange)range
2020
return NO;
2121
}
2222

23+
// Do not manually intervene if the user is in the middle of IME
24+
// composition. Let the iOS system handle the backspace natively to prevent
25+
// state desync.
26+
if (typedInput->textView.markedTextRange != nullptr) {
27+
return NO;
28+
}
29+
2330
// we make sure it was a backspace (text with 0 length) and it deleted
2431
// something (range longer than 0)
2532
if (text.length > 0 || range.length == 0) {

0 commit comments

Comments
 (0)