t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug][Mobile] Android link opens instead of allowing text selection after a long-press drag

Open superheher opened this issue 2 months ago • 2 comments

Steps to reproduce

  1. Open a chat containing a link on Android.
  2. Long-press the link and drag across the text to select it.
  3. Release your finger.

Expected

The text is selected and the Android copy/selection menu appears. Releasing after a selection drag must not open the link.

Actual

The link opens regardless of where the finger is released. The selection is lost, and there is no way to copy the link or selected text.

Environment

Android, T3 Code 1.3.0

superheher avatar Sep 26 '26 05:09 superheher

Confirmed on current main (5d707bb71d). Not already fixed. The Android link run is the same at the 1.3.0 bump (76cc9b08f1) and at the 1.3.1 bump (f5ef0ddb90, version only). Updating the app will not change this.

No open issue covers it. #13658 is the opposite iOS problem: a long-press there only starts a selection, and that PR adds UIKit’s link menu. Its description says Android ignores linkUrl and keeps a plain Text. #8779 is what made this text selectable. It did not change what a link does on finger-up.

What you hit

On Android, chat markdown is one selectable React Native Text. Each link is a nested Text whose onPress opens the URL. A tap and a selection drag share that handler.

MarkdownTextPrimitive uses React Native Text on Android. The parent is selectable. The link run always gets onPress when it has an href:

        const onPress = href
          ? () => {
              if (props.onLinkPress) props.onLinkPress(href);
              else void Linking.openURL(href);
            }
          : undefined;
        return (
          <MarkdownTextPrimitive
            // ...
            onPress={onPress}

That press is onMarkdownLinkPress in ThreadFeed.tsx, which calls tryOpenExternalUrl for an http(s) link. The same run is used for file links, so a selection drag that starts on a file reference opens the file instead.

React Native 0.86.3 Pressability calls onPress on finger-up whenever the touch is still “inside”. A long-press suppresses that only when the run also has onLongPress. These runs do not. Nested Text is not a real view, so measure on it comes back empty and Pressability never records a press rect. With no rect, a move does not count as leaving the link. Finger-up still runs onPress wherever you release.

The parent Text does start Android’s selection on the long-press. Opening the URL then dismisses that selection, so the copy menu never stays up.

Text that is not a link is unaffected. The gesture has to start on the link.

Direction

A tap on a link should still open it. A drag that starts on a link should leave the selection in place and show the Android selection menu.

An empty onLongPress is not enough. Pressability only uses that to cancel onPress after the long-press delay, and only while it still thinks the finger is inside. Ignore the press when the finger has moved. Do not use #13658’s iOS linkUrl path for this. Android does not read that prop.

Workaround. Start the selection on ordinary text and drag onto the link. The per-message copy button still copies the whole message. There is no way to start a selection on the link itself.

juliusmarminge avatar Sep 26 '26 05:09 juliusmarminge

[!NOTE] 🤖 Claude Opus 5.5 responding on behalf of Theo

Thanks for the report. One part of this is fixed on main in #16979. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: Android link selection after a drag was not specifically verified. If that part still matters to you, please open a new issue for that part only.

t3dotgg avatar Oct 21 '26 11:10 t3dotgg