Skip to content

fix: last paragraph styles applying on android - #116

Merged
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/android-last-paragarph-styles-applying
Jul 12, 2026
Merged

fix: last paragraph styles applying on android#116
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/android-last-paragarph-styles-applying

Conversation

@IvanIhnatsiuk

Copy link
Copy Markdown
Collaborator

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 textVersion counter 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:

  • Added a textVersion property to EnrichedTextInputView for tracking text changes more efficiently, replacing previous string comparison logic in selection handling.
  • Updated EnrichedTextWatcher to use an isApplyingInternalTextChange flag and a runWithInternalTextChange method, preventing unnecessary event emissions and recursive updates during internal text modifications.
  • Improved event emission logic to emit a generic content change event when shouldEmitOnChangeText is false, ensuring consistent event handling.

Paragraph and Span Handling Enhancements:

  • Fixed zero-width space (ZWS) handling in ParagraphStyles, ensuring correct span application and insertion logic for paragraphs without real text.
  • Refactored paragraph style state management to pass and use explicit paragraph selection ranges, improving reliability and maintainability.

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

  1. Open the editor
  2. Remove default text
  3. Type any text
  4. Insert new line
  5. Type some text
  6. Try to apply paragraph or list styles

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

OS Implemented
iOS
Android

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@IvanIhnatsiuk
IvanIhnatsiuk merged commit 313f26f into development Jul 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants