fix(mobile): keep Android markdown icons aligned #11118
main fromrefs/pull/11118/head·merged by juliusmarminge View on GitHubWhat Changed#
Keep Android Markdown text in a SpannableStringBuilder so inline file and link icons stay vertically aligned. This uses the existing native text hook and preserves selection across the whole message.
This addresses the vertical drift from #11079, which was reverted in #11098. Icon wrapping is a separate issue and is not addressed by this change. An icon can still stay on the previous line when its filename wraps.
Why#
React Native measures text with SpannableStringBuilder, but Android's selectable TextView normally converts it to SpannableString. After React Native exhausts its 256 span priorities, those buffer types can apply overlapping line-height spans in different orders. Icons use the measured baselines while text uses the displayed layout, so they drift apart.
A small Spannable.Factory override keeps measurement and display consistent. This is Android native code and requires a new Android binary to ship.
Verified with a release build on a physical Redmi Note 8 Pro running Android 11. The minimal case, 18 plain bullets followed by one file-reference bullet, went from 11 px of drift to zero. The vertical drift in the original nested-list reproduction is fixed too. Whole-message selection works, and copied text matches the unchanged app.
UI Changes#
Same message on the same phone, before and after:
| Before | After |
|---|---|
![]() | ![]() |
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes. Not applicable; this fixes static layout.
Model: GPT-6. Harness: Codex. Credits @SunkenInTime for a good reproduction
Summary by CodeRabbit#
- Bug Fixes
- Improved Android markdown text handling to preserve inline image ordering during text measurement and selection.
- Enhanced consistency when copying markdown content containing inline images.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
Approvability#
Verdict: Approved at
423dfc7Macroscope's review found this PR approvable — This is a small, isolated Android rendering bug fix that standardizes the Spannable buffer used by existing selectable markdown text, affecting only inline-icon alignment. It introduces no new capability, schema change, product-default change, or static-analysis suppression.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
bbd09d9f-d462-4e6b-8605-cbac494be941📥 Commits
Reviewing files that changed from the base of the PR and between dfa345b3697a9117364cc6730a1598d6c27096f2 and 423dfc7a276c2d672641bac25cc1fc7c4ff0fa2e.
📒 Files selected for processing (1)
apps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.kt
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The Android selection module now uses
MarkdownSpannableFactoryto createSpannableStringBuildermeasurement buffers and installs it on eligibleTextViewinstances.Changes#
Android spannable selection
Layer / File(s) Summary Spannable factory wiring
apps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.ktAdds MarkdownSpannableFactoryand assigns it to eligibleTextViewinstances before installing the selection action-mode callback.Estimated code review effort: 2 (Simple) | ~10 minutes
Suggested reviewers:
juliusmarminge,sunkenintimeMerge Risk: ⚪ Minimal · up to
423dfThis Android-only change keeps Markdown icons aligned while preserving selection and copied text behavior. No merge-blocking production risk remains beyond normal checks.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Description check ✅ Passed The description covers what changed, why it changed, testing results, scope limits, UI screenshots, and the checklist. It is complete and aligned with the repository template. Title check ✅ Passed The title clearly and concisely describes the main change: fixing Android Markdown icon alignment. - Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge merged this32b6909
juliusmarminge closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes