Skip to content

Commit 5c28968

Browse files
fix(android): remove heading style when backspacing ZWS (#626)
# Summary Fixes: #476 ## Test Plan Test if the backspace at the beginning of heading properly removes heading style. ## Screenshots / Videos https://github.com/user-attachments/assets/88bd3ce7-18d9-4d7b-9307-ac1e84104107 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ❌ | | Android | ✅ | ## Checklist - [x] E2E tests are passing - [ ] Required E2E tests have been added (if applicable)
1 parent b4c762f commit 5c28968

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,21 @@ class ParagraphStyles(
338338
}
339339

340340
if (isNewLine) {
341-
if (!config.isContinuous) {
342-
spanState.setStart(style, null)
343-
continue
344-
}
345-
346341
// If removing text at the beginning of the line, we want to remove the span for the whole paragraph
347342
if (isBackspace) {
348343
val currentParagraphBounds = s.getParagraphBounds(endCursorPosition)
349344
removeSpansForRange(s, currentParagraphBounds.first, currentParagraphBounds.second, config.clazz)
350345
spanState.setStart(style, null)
351346
continue
352-
} else {
353-
s.insert(endCursorPosition, EnrichedConstants.ZWS_STRING)
354-
endCursorPosition += 1
355347
}
348+
349+
if (!config.isContinuous) {
350+
spanState.setStart(style, null)
351+
continue
352+
}
353+
354+
s.insert(endCursorPosition, EnrichedConstants.ZWS_STRING)
355+
endCursorPosition += 1
356356
}
357357

358358
var (start, end) = s.getParagraphBounds(styleStart, endCursorPosition)

android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class EnrichedTextWatcher(
4141

4242
if (view.isDuringTransaction) return
4343
applyStyles(s)
44+
view.layoutManager.invalidateLayout()
4445
}
4546

4647
private fun applyStyles(s: Editable) {

0 commit comments

Comments
 (0)