fix: correct scroll position when insert text on Android#100
Merged
IvanIhnatsiuk merged 2 commits intoJun 9, 2026
Merged
Conversation
There was a problem hiding this comment.
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/canScrollHorizontallyto respect bothscrollEnabledand 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.
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 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:
correctScrollPositionIfNeeded()method inEnrichedTextInputView, 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.canScrollVerticallyandcanScrollHorizontallyto also check the superclass's scrollability, not just thescrollEnabledflag, for more accurate scrolling behavior.Code Quality and Encapsulation:
viewproperty inEnrichedStyleManipulatorfromval(public) toprivateto better encapsulate internal state.Test Plan
Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:
Screenshots / Videos
Include any visual proof that helps reviewers understand the change — UI updates, bug reproduction or the result of the fix.
Compatibility