From 54d9484144b14876316e8808953052981838dba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20=C5=BB=C3=B3=C5=82kiewski?= Date: Tue, 2 Jun 2026 14:37:32 +0200 Subject: [PATCH] fix(android): remove heading style when backspacing ZWS --- .../enriched/textinput/styles/ParagraphStyles.kt | 16 ++++++++-------- .../textinput/watchers/EnrichedTextWatcher.kt | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt b/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt index 09b06271d..c409035dc 100644 --- a/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +++ b/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt @@ -338,21 +338,21 @@ class ParagraphStyles( } if (isNewLine) { - if (!config.isContinuous) { - spanState.setStart(style, null) - continue - } - // If removing text at the beginning of the line, we want to remove the span for the whole paragraph if (isBackspace) { val currentParagraphBounds = s.getParagraphBounds(endCursorPosition) removeSpansForRange(s, currentParagraphBounds.first, currentParagraphBounds.second, config.clazz) spanState.setStart(style, null) continue - } else { - s.insert(endCursorPosition, EnrichedConstants.ZWS_STRING) - endCursorPosition += 1 } + + if (!config.isContinuous) { + spanState.setStart(style, null) + continue + } + + s.insert(endCursorPosition, EnrichedConstants.ZWS_STRING) + endCursorPosition += 1 } var (start, end) = s.getParagraphBounds(styleStart, endCursorPosition) diff --git a/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt b/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt index 028b41c15..97fa1d7f5 100644 --- a/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt +++ b/android/src/main/java/com/swmansion/enriched/textinput/watchers/EnrichedTextWatcher.kt @@ -41,6 +41,7 @@ class EnrichedTextWatcher( if (view.isDuringTransaction) return applyStyles(s) + view.layoutManager.invalidateLayout() } private fun applyStyles(s: Editable) {