Repository navigation
fix(android): a long-press on a link no longer also opens selection or block menus - #5
Merged
juliusmarminge merged 1 commit intoOct 16, 2026
Conversation
…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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.onTouchEventposts the view's long-press callback beforeLinkLongPressMovementMethodseesACTION_DOWNand posts the link runnable with the same timeout. The runnable callswidget.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:
scheduleLongPresscallswidget.cancelLongPress(). It only runs for anACTION_DOWNon 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-mobilewithout 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
./gradlew :ui:testDebugUnitTest --tests "*LinkLongPressInteractionTest*"and:ui:ktlintCheckpass. 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.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.