fix(android): preserve inline styles during IME composition - #737
Open
woosanggyu wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an Android-only IME composition edge case where predictive keyboards (via repeated setComposingText) can drop previously-applied enriched inline style spans when an inline style is toggled mid-word. The change adds targeted span snapshot/restore logic in the Android InputConnection wrapper so only unchanged parts of the composing word keep their prior inline styling.
Changes:
- Adds an inline-style restoration helper to reapply a specific inline style span over a given range when missing.
- Tracks when inline-style preservation should run (only after an inline style is toggled during an active composing region).
- Snapshots inline spans inside the composing range before
setComposingText/commitText, then restores them over the unchanged prefix/suffix, clearing state when composition is committed/finished.
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/textinput/styles/InlineStyles.kt | Adds restoreStyleOnRange to reapply a specific inline style span when absent. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt | Stores the wrapped InputConnection and triggers preservation when toggling inline styles. |
| android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputConnectionWrapper.kt | Implements composing-range snapshot + restore around IME updates and clears preservation state appropriately. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hejsztynx
self-requested a review
July 31, 2026 10:26
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
Fixes #734.
On Android, predictive keyboards replace the entire active composing word on each
setComposingTextcall. When an inline style was toggled off in the middle of that word, the replacement discarded enriched inline spans that belonged to the unchanged prefix.This change:
setComposingTextorcommitText;The change is limited to the Android text input implementation.
Test Plan
Manual verification in the example Android app with Gboard predictive text / suggestions enabled:
abc.defwithout a space.ghiwithout a space.defremains bold.Automated checks:
yarn lintpassed.yarn typecheckpassed.yarn test --maxWorkers=2passed (415 tests).Screenshots / Videos
See the reproduction video in #734. The fix does not change layout or visual design.
Compatibility
Checklist