Skip to content

fix: correct scroll position when insert text on Android#100

Merged
IvanIhnatsiuk merged 2 commits into
developmentfrom
fix/correct-scroll-position-on-android-when-insert-text
Jun 9, 2026
Merged

fix: correct scroll position when insert text on Android#100
IvanIhnatsiuk merged 2 commits into
developmentfrom
fix/correct-scroll-position-on-android-when-insert-text

Conversation

@IvanIhnatsiuk

Copy link
Copy Markdown
Collaborator

Summary

This pull request improves the behavior of scrolling and style manipulation in the enriched text input component. The main focus is on ensuring the scroll position is updated correctly when paragraph styles are changed, and on making scrolling behavior more consistent and predictable. Additionally, there are some code quality improvements for better encapsulation and clarity.

Scroll and Layout Behavior Improvements:

  • Introduced the correctScrollPositionIfNeeded() method in EnrichedTextInputView, which ensures the view scrolls to the correct position after certain style changes or text updates. This method is now called after removing or toggling paragraph styles and after text changes.
  • Updated canScrollVertically and canScrollHorizontally to also check the superclass's scrollability, not just the scrollEnabled flag, for more accurate scrolling behavior.

Code Quality and Encapsulation:

  • Changed the visibility of the view property in EnrichedStyleManipulator from val (public) to private to better encapsulate internal state.

Test Plan

Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:

  • Steps to reproduce the bug (if this is a bug fix)
  • Steps to verify the new feature
  • Expected vs actual results
  • Any special conditions or edge cases to test

Screenshots / Videos

Include any visual proof that helps reviewers understand the change — UI updates, bug reproduction or the result of the fix.

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 improves Android scroll behavior in EnrichedTextInputView so the caret remains correctly visible after text mutations and certain style operations, addressing incorrect scroll position when inserting text / manipulating paragraph styles.

Changes:

  • Added correctScrollPositionIfNeeded() to centralize “scroll-to-selection” correction and invoked it after text changes and paragraph style operations.
  • Refined canScrollVertically / canScrollHorizontally to respect both scrollEnabled and the superclass’ actual scrollability.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
android/src/main/java/com/swmansion/enriched/watchers/EnrichedTextWatcher.kt Calls scroll correction after afterTextChanged processing to keep selection visible after edits.
android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt Improves scrollability checks and introduces correctScrollPositionIfNeeded() (delegating to existing selection-based scrolling).
android/src/main/java/com/swmansion/enriched/EnrichedStyleManipulator.kt Encapsulates the view reference and triggers scroll correction after paragraph-style toggle/removal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IvanIhnatsiuk IvanIhnatsiuk merged commit 06b9d56 into development Jun 9, 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