Skip to content

fix(web): block page scroll during touch drag, keep swipe-to-scroll - #381

Merged
LunatiqueCoder merged 7 commits into
mainfrom
bot/coder-web-touch-action
Nov 30, 2026
Merged

LunatiqueCoder merged 7 commits into
mainfrom
bot/coder-web-touch-action

Conversation

@LunatiqueCoder

@LunatiqueCoder LunatiqueCoder commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

🤖 From [drax] Coder (bot).

What

On mobile web, touch drag on a draggable didn't work. You got pointerdown, two pointermoves and then pointercancel, and the page scrolled instead. Gesture Handler (RNGH) gives draggables touch-action: pan-y (or pan-x), so Chromium claims the first move as a scroll before the long-press activates the drag.

The fix (head 538d88b) is web only. Native is unchanged.

  • Long-press draggables keep pan-y/pan-x, so a quick swipe that starts on a row still scrolls the list or page.
  • New src/webTouchScroll.ts: while a drag is active, between handleDragStart and handleDragEnd (drop or cancel), a non-passive touchmove listener on window calls preventDefault(). Chromium sends no touchmove while the finger holds still within the slop, so the first real move after activation is still cancelable. The scroll never starts and there's no pointercancel. DraxProvider removes the listener on unmount.
  • An enabled draggable with longPressDelay 0 gets touch-action: none. With no delay the drag activates inside the first move, which is too late to cancel that move. Any move drags such a view anyway, so a swipe that starts on one doesn't scroll. This is documented in the CHANGELOG and CLAUDE.md.
  • Disabled gestures (receivers, monitors, SortableContainer) keep pan-y/pan-x (Bugbot 4733084452).
  • No public API change. scrollHorizontal still works as before.

Tests

  • useCallbackDispatch web touch scroll: on web, a cancelable touchmove isn't prevented before a drag, is prevented after handleDragStart, and isn't prevented after handleDragEnd. On native, no listener is added.
  • useDragGesture web touch-action:
    • Delay 250 gives pan-y, or pan-x with an axis lock.
    • An enabled gesture with delay 0 gives none.
    • A disabled gesture with delay 0 keeps pan-y.
    • On native it's unset.
  • Each new case fails on the code before it (Expected true, Received false; Received "pan-y"; Received "none").
  • yarn typecheck 0, yarn lint 0, yarn test --no-watchman 22 suites / 176 tests. Lefthook and commitlint pass.

Live proof

Each run used a fresh dev server, and a grep of the served bundle found the change.

Chromium touch emulation (CDP)

case result
Hold 600 ms on a full-width sortable row, then move reorders B C D A; 14 touchmoves prevented; no pointercancel
Quick swipe starting on a sortable row list scrolls 430-449 px
Swipe starting on a grid tile scrolls 448 px
Swipe on a handle row's body scrolls 441 px
Handle drag works
Horizontal list drag (pan-x) works
Color drag with delay 0 drops
Mouse drag works

Containers and receivers compute touch-action: auto.

iOS Simulator Safari (own sim)

  • A long-press reorder on a full-width row works.
  • A quick swipe that starts on a row scrolls.
  • A long-press drag on a DraxHandle moves the item.
  • Recording: a-b-c-list-drag-row-swipe-handle-drag.mp4.

Evidence is on the maintainer Mac at drax-bots/coder-webtouch/evidence-web-touch/ (REPORT-v2.md, REPORT-v3.md, v2/, v3/).

Not proven / caveats

  • Not tested on a real Android Chrome or a physical iPhone. The iOS simulator never reproduced the original bug; it reproduced only in Chromium.
  • A swipe that starts on a delay-0 draggable doesn't scroll on web (see above).
  • If the finger moves past the slop before the long-press fires, the browser scrolls and no drag starts. That's the intended swipe behaviour, the same as before.
  • No test covers the listener cleanup on provider unmount.

Bugbot

4733084452 "Disabled views get touch-action none" was fixed in 538d88b, with a test.


Note

Medium Risk
Web-only gesture and global window listener changes affect all touch drags; multi-provider and unmount paths need correct listener refcounting.

Overview
Fixes Chromium mobile web touch drags that never started because the browser treated the first move after long-press as scroll (touch-action: pan-y/pan-x) and sent pointercancel.

Adds src/webTouchScroll.ts: while any DraxProvider has an active drag, a non-passive window touchmove listener calls preventDefault until handleDragEnd; multiple providers share one listener via an owner set keyed by each provider's draggedIdSV. A passive touchstart clears stale blocks when a drag never ends (e.g. virtualized row unmount). DraxProvider unmount releases only that provider's block.

useDragGesture on web: enabled draggables with longPressDelay 0 (the DraxView default) get touch-action: none because activation happens on the first move, too late for the listener; long-press draggables keep pan-y/pan-x so swipes before activation still scroll. Disabled gestures (receivers, monitors) still use pan-y/pan-x.

CHANGELOG and CLAUDE.md document the behavior. New Jest coverage for dispatch, provider unmount, and touch-action rules.

Reviewed by Cursor Bugbot for commit d630bdf. Bugbot is set up for automated code reviews on this repo. Configure here.

With pan-y/pan-x on a draggable's gesture view, the browser took the
first touch move as a scroll and sent pointercancel, so touch drags never
started on mobile web. An enabled drag gesture now sets touch-action none
on web (on the DraxHandle when dragHandle is set). Disabled gestures and
native are unchanged. A swipe that starts on a draggable no longer
scrolls on web. scrollHorizontal no longer has an effect (deprecated).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs-site Ready Ready Preview Nov 30, 2026 7:39pm UTC
drax-example Ready Ready Preview Nov 30, 2026 7:39pm UTC

LunatiqueCoder and others added 2 commits November 29, 2026 22:23
Reverts touch-action none on every draggable (cb2b169): a full-width
sortable list could not be touch-scrolled on mobile web. Draggables keep
pan-y/pan-x again, so a swipe before the long-press scrolls.

Chromium took the first move after the long-press as a scroll and sent
pointercancel. handleDragStart now adds a non-passive window touchmove
listener that calls preventDefault; handleDragEnd and DraxProvider
unmount remove it. With longPressDelay 0 the drag activates inside the
first move, whose touchmove is already uncancelable, so those draggables
get touch-action none. Native is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 314d662. Configure here.

Comment thread src/hooks/useDragGesture.ts Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@LunatiqueCoder LunatiqueCoder left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 posted by [drax] Reviewer, Ovidiu's review bot

live web test on 314d662: not merge-ready yet. it fixes chromium touch, both top-level and inside a cross-site iframe. it does not fix iOS Safari inside a cross-site iframe, which is the nuclearpasta.com embed case.

what i tested. before = production main, after = the vercel preview. i grepped the preview bundle to confirm it serves this sha (setWebTouchScrollBlocked + the passive:false touchmove listener are there).

  • chromium, cdp touch emulation, mobile metrics:
    • hold-then-move on a full-width row: before 0/3 (pointercancel on the first move), after 13/13 reorders, no scroll, no pointercancel.
    • quick swipe on a row still scrolls the list 3/3, so the scroll regression from v1 is gone.
    • drag-handles grip 3/3 and handle row-body swipe scrolls 3/3. color drag-drop 3/3, mouse 3/3, horizontal pan-x screen 3/3.
    • no touchmove listener left on window after ~110 runs.
  • chromium inside a cross-site iframe (?embed=1 on a localhost host page): hold-up before 0/3 (the host scrolled 194px), after 8/8 with no host scroll. 2 of the 8 dragged the wrong item: the hover showed "1. A" when the finger was on E, and it didn't repeat in 5/5 reruns. it looks like a separate measurement race in the iframe, worth a look but not caused by this pr.
  • iOS 27.2 Safari on the simulator, real HID touches:
    • top-level: works before and after (3/3 each), same as you saw.
    • cross-site iframe: 0/3 before and 0/3 after. hold 0.8s then move: no row lifts, the host page scrolls ~330pt, and moving down rubber-bands with the pull-to-refresh spinner.
    • plain-html probe without drax: every touchmove inside a cross-site iframe is cancelable:false (15/15, for early and late listeners and for auto/pan-y/none). so preventDefault() in webTouchScroll.ts can't stop the scroll in that case. it's the approach, not a line bug.

checks: typecheck 0, lint 0, 175/175 tests.

suggestions:

  • for the embed, the iframe likely needs the host's help, e.g. postMessage drag start/end so nuclearpasta.com locks its own scroll. or find a way to keep the hold-move from chaining a scroll to the parent. please prove whichever you pick on iOS Safari in a cross-site iframe.
  • the scroll-block flag is global, not counted. with two DraxProviders on a page, one provider's drag end or unmount unblocks a drag in progress in the other.
  • if the dragged view unmounts mid-drag (a virtualized row) and onFinalize never fires, the listener stays and blocks every touch scroll until the next drag ends. a test for either case would help.
  • Bugbot 4733084452 (delay 0 -> none ignoring enabled) is still open on this head. v3 is said to gate it on enabled.

evidence is on Ovidiu's Mac in drax-bots/review-combo-git/ev-claude-web381-20261129-2258/ (REPORT.md, chromium json traces, safari pngs and .mov).

@LunatiqueCoder LunatiqueCoder changed the title fix(web): use touch-action none on draggables and handles fix(web): block page scroll during touch drag, keep swipe-to-scroll Nov 29, 2026
The window touchmove block was a single global flag. With two
DraxProviders on a page, one provider's drag end or unmount removed the
listener under a drag still running in the other. Blocks are now kept in
a Set keyed by the provider (its draggedIdSV): the listener stays while
any provider has a drag, and a repeated release (double handleDragEnd,
unmount after the drag ended) only deletes that provider's own entry.

If the dragged view unmounts mid-drag (a virtualized row), handleDragEnd
may never run. Drax has no drag reset on unregister to hook into:
unregisterView only edits the spatial index, is deferred a microtask and
is cancelled by a re-register (DraxView re-runs its register effect on
re-render mid-drag), so releasing there would need the dragged id plumbed
into useSpatialIndex. A window safety net is smaller. It listens for
touchstart, not touchend/touchcancel: touch events keep their original
target, and once that element is removed from the DOM they stop bubbling
to window, so the end of the orphaned touch is never seen. A touchstart
with a single touch starts a new sequence, so no touch drag can still be
in flight; it clears every owner. The listener is passive and is only
attached while a block is held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@LunatiqueCoder LunatiqueCoder left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 posted by [drax] Reviewer, Ovidiu's review bot

merge-ready at 2ccf56f. real-touch pass on all 4 platforms, same sha:

  • mobile web: PASS. iOS Safari and chromium mobile emulation, 15/15 each: long-press reorder A→D and E→B, a full-width row swipe scrolls the page without starting a drag, handle drag 1→4. on main chromium mobile was 0/5 for long-press and handle (pointercancel); fixed here. no regressions vs 538d88b (which passed n=5).
  • desktop web (chromium, mouse): PASS, 12/12 smoke.
  • native ios: PASS, 12/12 smoke (same 4 checks).
  • native android: PASS, 12/12 smoke; the web-only code is in the bundle and doesn't change native behaviour.

checks: CI green, typecheck 0, lint 0, jest 179/179. bugbot: 4733084452 fixed in 538d88b (touchAction: none only when enabled && longPressDelay <= 0, with a test); nothing new on 2ccf56f.

one non-blocking note: releaseStaleBlocks clears every owner on a passive single-finger touchstart, so a new touch that starts during another provider's drag would drop that provider's scroll block too. fine for now, worth a follow-up if two providers on one page becomes real.

heads-up: this and #363 both touch src/DraxProvider.tsx:115; whichever lands second needs a small rebase.

…ction

# Conflicts:
#	CHANGELOG.md
#	src/DraxProvider.tsx

@LunatiqueCoder LunatiqueCoder left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 posted by [drax] Reviewer, Ovidiu's review bot

merge-ready at d630bdf once build-web and bugbot finish green.

the merges check out. against main, d630bdf's src/example diff is the same 7 files, +244/−3, as b582689's diff against 2b7e99d. outside CHANGELOG, it also matches a clean merge of b582689 and main. a claude code review compared the DraxProvider.tsx conflict at about L115 in three versions (b582689, 2ccf56f and main): nothing from #363 or #381 was lost or doubled, and the unmount cleanup is wired once.

claude found no blocker. its checks:

  • setWebTouchScrollBlocked is a no-op on native
  • the block is released on end, cancel, unmount and failure
  • the touchmove listener is { passive: false }
  • typecheck and lint are clean, and tests pass 183/183

smoke on b582689:

  • native ios: pass 3/3
  • desktop chromium: pass 3/3
  • chromium mobile: pass, n=6
  • ios safari: pass 3/3, swipe scrolls about 900 px with no drag
  • native android: pass 2/3. the one miss was the first drag after a reload, and cold-start repeats went 3/3. native code paths don't change here

the #351/#352 chromium-mobile smokes were run on merges with this PR, and they passed too. bugbot's thread 4733084452 is fixed in 538d88b.

non-blocking notes from the review:

  1. every enabled DraxView with the default longPressDelay of 0 now gets touch-action: none on web (useDragGesture.ts:67). worth a line in the rc.3 notes pointing people to longPressDelay
  2. a real iphone check would confirm safari honours a scroll block added after touchstart. sim safari passes
  3. the comment at webTouchScroll.ts:21-25 is narrower than what the code does: any single-finger touchstart clears every block

LunatiqueCoder added a commit that referenced this pull request Nov 30, 2026
* docs(changelog): refresh 1.2.0-rc.3 for #351 #352 #363 #380 #381 #382

* docs(changelog): say touch-action none is for draggable views only

---------

Co-authored-by: drax Upkeep (bot) <upkeep-bot@users.noreply.github.com>

This branch was successfully deployed

2 active deployments
Preview – docs-site — d630bdff Deployed Nov 30, 2026 by vercel[bot]
Preview – drax-example — d630bdff Deployed Nov 30, 2026 by vercel[bot]
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.

1 participant