Skip to content

[Bug]: iOS text selection is invisible inside a code block nested in a list #20903

Closed as not planned

Description

@camchis

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. In the iOS app, open a thread with an assistant message that contains a fenced code block inside a list item, for example:

    - Install the next channel:
    
      ```sh
      npm i -g @example/demo-cli@next
      ```
  2. Long-press a word inside the code block, then drag a handle across more of it.

Expected behavior

The selected code is highlighted, as it is in ordinary text.

Actual behavior

Handles and the Copy / Copy as Markdown / Look Up menu appear, and Copy copies exactly the selection, but nothing inside the code block is highlighted.

This is an upstream Enriched bug on iOS: software-mansion/enriched-markdown#1024. UIKit draws the selection highlight beneath the text, and Enriched painted the code block's box in the text drawing, covering it. T3's code block background (--color-md-code-bg) is opaque, so the highlight is fully hidden; making the box translucent lets it show through.

Only code blocks nested in a list hit this in T3. Top-level code blocks render as a separate view, and T3 already gives inline code and quotes transparent backgrounds.

Proposed fix (in discussion upstream, see the issue above): draw Enriched's boxes beneath the highlight. Once that lands, sync pingdotgg/enriched-markdown (fork/t3-mobile) and bump apps/mobile/deps/react-native-enriched-markdown-*.tgz. It's native code, so it ships in a new native build, not an OTA update.

Impact

Minor bug or occasional failure

Version or commit

main @ 98a6246d07 (clean checkout)

Environment

iOS 26.5 Simulator (iPhone 17 Pro) and a physical iPhone

Screenshots, recordings, or supporting files

Code block in a list item, text selected Same gesture on the paragraph below (control)

Workaround

Copy still works, so select and copy without the highlight.

Activity

  1. camchis commented on Oct 17, 2026

    @camchis
    ContributorAuthor

    Proposed upstream fix, opened as a draft for discussion: software-mansion/enriched-markdown#1025 (fixes software-mansion/enriched-markdown#1024). Once it lands upstream, the fork sync and tarball bump described above are the only T3 changes needed.

  2. juliusmarminge commented on Oct 17, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    I'm closing this as upstream. As you found, Enriched draws the code-block box on top of UIKit's selection highlight, and that's tracked in software-mansion/enriched-markdown#1024. Once it's fixed there, the fix can come in with a sync of our Enriched fork.

    On our side, apps/mobile/src/native/EnrichedMarkdownText.tsx already sets inline code and blockquote backgrounds to transparent. codeBlock uses codeBlockBackgroundColor, which ThreadFeed.tsx fills from --color-md-code-bg. Making that translucent here would change how every assistant code block looks, just to work around a native drawing-order bug, so it isn't something we'd change as a bug fix.

    Copy still works in the meantime. If #1024 is closed without a fix, comment here and we'll look at it again.

  3. added
    via-triage
    on Oct 17, 2026
  4. hryhoriiK97 commented on Oct 17, 2026

    @hryhoriiK97

    Heads-up from the Enriched side: we're closing software-mansion/enriched-markdown#1024 without a library fix. On iOS 18+ UIKit draws the selection highlight beneath the text, and Apple's own NSBackgroundColorAttributeName has the same problem, so a real fix means mirroring every background in a separate layer tree and re-laying out the whole document on each update. Too costly for a cosmetic issue in a streaming-heavy renderer. Reasoning in software-mansion/enriched-markdown#1025.

    Since only list-nested code blocks hit this in T3, the lightest option is to pass a translucent variant of --color-md-code-bg as codeBlockBackgroundColor for the native view (something like 85% alpha keeps the box visually the same while letting the highlight through). Otherwise leaving it as is, with Copy working, is reasonable.

  5. camchis commented on Oct 19, 2026

    @camchis
    ContributorAuthor

    Following up as suggested: Enriched closed software-mansion/enriched-markdown#1024 without a library fix (reasoning in software-mansion/enriched-markdown#1025 or see above) and recommended a translucent box instead.

    Proposal: pass a see-through version of --color-md-code-bg as the native codeBlockBackgroundColor. Its opacity and color are chosen so that, over --color-screen, it gives the current color. Code blocks keep their look and the selection highlight shows through.

    • New seeThroughThemeColor(color, surface) in mobileTheme.ts. It uses 25% opacity, or the least opacity that still matches exactly, capped at 50%.
    • It matches exactly in every built-in theme except T3 Code light. There the box is white on a #fcfcfc page, which nothing below full opacity can reproduce, so it uses 50%. The unit test covers every theme in both appearances and allows at most 2 levels of difference; on the simulator the light screen came out identical.
    • Only the assistant nativeTextStyle changes. User bubbles, file previews and PR Markdown keep their colors.

    iOS 26.5 simulator, current main vs. with the change (code block nested in a list, word selected):

    Before After
    T3 Code light
    T3 Code dark
    • With nothing selected, the screen is pixel-identical before and after in light and dark, including a top-level code block and a table that share this color.
    • In light mode the highlight shows at half strength, because of the 50% cap.
    • I haven't run Android. It doesn't have the bug, and the color looks the same over the screen, but I haven't checked it on a device.

    It's +60/−2 across three files, with tests. I'll open a PR shortly.

    Thanks @hryhoriiK97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamvia-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions