Skip to content

Commit 982c0ca

Browse files
fix(iOS): merge inline style with plain text (#722)
# Summary This PR fixes merging inline style with plain text. This regression was introduced in this PR: #551 ## Test Plan 1. run example app 2. toggle bold 3. type `first line` 4. toggle off bold 5. type `second` 6. go with the cursor before `second` and remove last bolded letter 7. bold style should not exceed on `second` word ## Screenshots / Videos Before: https://github.com/user-attachments/assets/92bc0425-9565-4acb-8ffe-359eab6aa9f0 After: https://github.com/user-attachments/assets/38ea98fe-e497-4da2-9d31-6823702ff92b ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ | | Web | ❌ | ## Checklist - [x] E2E tests are passing - [x] Required E2E tests have been added (if applicable)
1 parent 039fd28 commit 982c0ca

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
appId: swmansion.enriched.example
2+
---
3+
# Fix: merge inline styles with plain text
4+
- launchApp
5+
6+
- tapOn:
7+
id: 'toggle-screen-button'
8+
9+
- tapOn:
10+
id: 'editor-input'
11+
12+
- tapOn:
13+
id: 'toolbar-bold'
14+
- tapOn:
15+
id: 'toolbar-italic'
16+
- tapOn:
17+
id: 'toolbar-underline'
18+
19+
- inputText: 'First line'
20+
- pressKey: Enter
21+
22+
- tapOn:
23+
id: 'toolbar-bold'
24+
- tapOn:
25+
id: 'toolbar-italic'
26+
- tapOn:
27+
id: 'toolbar-underline'
28+
- inputText: 'Second line'
29+
30+
- tapOn:
31+
id: 'editor-input'
32+
point: '5%,75%'
33+
34+
- pressKey: Backspace
35+
36+
- runFlow:
37+
file: '../subflows/capture_or_assert_screenshot.yaml'
38+
env:
39+
SCREENSHOT_NAME: 'inline_styles_merge'
6.9 KB
Loading
8.9 KB
Loading

ios/EnrichedTextInputView.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,8 +1920,9 @@ - (bool)textView:(UITextView *)textView
19201920
replacementText:(NSString *)text {
19211921
// Capture the attributes at range.location that are being replaced
19221922
// (autocorrect / predictive) so didProcessEditing: can re-stamp them onto the
1923-
// replacement.
1924-
if (range.length > 0) {
1923+
// replacement. Only capture for genuine replacements (text.length > 0), not
1924+
// for deletions/backspace (text.length == 0).
1925+
if (range.length > 0 && text.length > 0) {
19251926
_capturedAttributesBeforeChange =
19261927
[textView.textStorage attributesAtIndex:range.location
19271928
effectiveRange:NULL];

0 commit comments

Comments
 (0)