Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): keep Android markdown icons aligned #11118

Mergednone23(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/11118/headmerged by juliusmarminge View on GitHub

What 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:

BeforeAfter
Before: file and GitHub icons drift below their labels on AndroidAfter: inline icons stay vertically aligned; icon wrapping is a separate issue

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 labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at 423dfc7

      Macroscope'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).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      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 MarkdownSpannableFactory to create SpannableStringBuilder measurement buffers and installs it on eligible TextView instances.

      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.kt
      Adds MarkdownSpannableFactory and assigns it to eligible TextView instances before installing the selection action-mode callback.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Suggested reviewers: juliusmarminge, sunkenintime

      Merge Risk: ⚪ Minimal · up to 423df

      This 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Description check✅ PassedThe 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✅ PassedThe 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.
    4. juliusmarminge merged this32b6909

    5. juliusmarminge closed this

Sign in to join this conversation.