fix: last paragraph styles applying on android - #116
Merged
IvanIhnatsiuk merged 1 commit intoJul 12, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Android enriched text input implementation to improve internal text-change handling and paragraph-style application, addressing the reported issue where the last paragraph’s styles weren’t applying correctly on Android.
Changes:
- Added an internal “text version” counter and switched selection validation from string comparison to version comparison.
- Prevented recursive/redundant watcher work and event emissions during internal text mutations (style application / cleanup).
- Refined paragraph-style/ZWS handling and refactored paragraph/list style state calculations to use explicit paragraph selection ranges.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt | Adds internal-change guarding and adjusts event emission behavior to avoid redundant/recursive updates. |
| android/src/main/java/com/swmansion/enriched/utils/EnrichedSelection.kt | Uses textVersion for change detection and threads paragraph selection explicitly into paragraph/list state logic. |
| android/src/main/java/com/swmansion/enriched/styles/ParagraphStyles.kt | Fixes ZWS handling for empty paragraphs and refactors non-editable paragraph insertion logic. |
| android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt | Introduces textVersion counter used by selection/state logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request introduces several improvements and bug fixes to the enriched text input system, focusing on internal state management, event emission, and paragraph style handling. The main changes include the introduction of a
textVersioncounter for efficient text change tracking, improved handling of internal text changes to avoid redundant event emissions, and enhanced logic for managing paragraph styles and spans.State and Event Management Improvements:
textVersionproperty toEnrichedTextInputViewfor tracking text changes more efficiently, replacing previous string comparison logic in selection handling.EnrichedTextWatcherto use anisApplyingInternalTextChangeflag and arunWithInternalTextChangemethod, preventing unnecessary event emissions and recursive updates during internal text modifications.shouldEmitOnChangeTextis false, ensuring consistent event handling.Paragraph and Span Handling Enhancements:
ParagraphStyles, ensuring correct span application and insertion logic for paragraphs without real text.These changes collectively enhance the stability and maintainability of the enriched text input system, reducing unnecessary updates and improving the handling of complex paragraph and span scenarios.
Test Plan
Screenshots / Videos
Before
Screen.Recording.2026-07-12.at.14.44.24.mov
After
Screen.Recording.2026-07-12.at.14.42.40.mov
Compatibility