Skip to content

fix(android): a long-press on a link no longer also opens selection or block menus - #5

Merged
juliusmarminge merged 1 commit into
pingdotgg:fork/t3-mobilefrom
voida6:fork/android-link-long-press-race
Oct 16, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:fork/t3-mobilefrom
voida6:fork/android-link-long-press-race

Conversation

@voida6

@voida6 voida6 commented Oct 16, 2026 •

Copy link
Copy Markdown

What/Why?

On Android, a long-press on a link in T3 Code sometimes opens two things at once: the link menu (onLinkLongPress) and the view's own long-press. In a paragraph that is text selection with its toolbar; in a table cell it is the table's Copy / Copy as Markdown menu.

Cause: View.onTouchEvent posts the view's long-press callback before LinkLongPressMovementMethod sees ACTION_DOWN and posts the link runnable with the same timeout. The runnable calls widget.cancelLongPress(), but that only helps when it runs first. On a Galaxy S25 Ultra the view's callback ran 1-11 ms first in most presses, so both fired.

Fix: scheduleLongPress calls widget.cancelLongPress(). It only runs for an ACTION_DOWN on a link, so a long-press on plain text is unchanged. The same 4 lines go into both Android implementations.

Upstream: software-mansion#1011 (open, unreviewed). This is the same commit, cherry-picked onto fork/t3-mobile without conflicts. It can be dropped when the fork syncs past the upstream merge. The full cause and the per-gesture before/after table are in that PR.

Testing

  • On this branch: ./gradlew :ui:testDebugUnitTest --tests "*LinkLongPressInteractionTest*" and :ui:ktlintCheck pass. The test fails without the fix (the view's long-click also fires) and passes with it. ktlint 1.8.0 passes on the changed React Native file.
  • Device: release build of T3 Code with this patch on a Galaxy S25 Ultra (Android 16). Table cell link: link menu only, 5 of 5 (before: two menus on 2 of 3). Paragraph link: link menu only, 2 of 2 (before: menu plus text selection, 3 of 3). Long-press on plain text and table text unchanged.

Before:

before-double-menus.mp4

After:

after-single-menu.mp4

iOS is unchanged.

Credit: when this ships in a T3 Code bump, could the bump commit include Co-authored-by: voida6 <289179128+voida6@users.noreply.github.com>? Thanks.

…r block menus

TextView posts its own long-press callback in View.onTouchEvent before
LinkLongPressMovementMethod sees ACTION_DOWN, and the link long-press
runnable uses the same timeout. The runnable cancelled the view's
long-press, but only when it happened to run first. When the view's
callback ran first, a long-press on a link opened the link long-press
and also text selection (paragraphs) or the block context menu (table
cells).

Cancel the view's long-press when the press lands on a link, before
scheduling the link long-press. A long-press on plain text is unchanged.
@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f6a44ab-edc0-45b0-8f10-90eec542f98c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge
juliusmarminge merged commit 16003cf into pingdotgg:fork/t3-mobile Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants