Select area no longer freezes the document on a phone - #164
Merged
Merged
Conversation
Reported: "there seems to be problems with the select area on mobile ... my guess would be it's linked to the touchscreen tap and swipe to move up and down on multiple pages". The guess was right. Select area needs a one-finger drag to draw its box; so does scrolling through the document, and the page could only give that gesture to one of them. It gave it to the box outright -- `touch-action: none` on every page's Konva Stage -- so picking Select area on a phone froze the document. Every swipe drew an empty selection box instead of scrolling, an empty sweep leaves the tool armed for another try, and there was no way to reach page 4, or to get out, short of going back to the toolbar and picking a different tool. Measured on a 390x844 touch context: a swipe with Select / Select text / Hand active moved the document ~385px, and with Select area active it moved 0. This is the same mistake the one-shot placement tools made and it takes the same shape of answer -- hand the plain swipe back to the document and ask for a gesture a swipe is not: * On a coarse pointer the Stage keeps `pan-y pinch-zoom` with Select area active, so swiping and pinching work exactly as they do with Select. * The box is started by a press-and-hold (350ms), then drag -- what a phone already means by "start selecting" everywhere else. An orange anchor dot marks the moment the hold lands, so the gesture is not invisible while it waits. * `touch-action` is read once, when the finger lands, so it cannot be flipped at hold time. A native non-passive touchmove listener claims the gesture with preventDefault instead, which still works because the finger has not moved and the scroll has not begun. A move that arrives non-cancelable means the browser kept the gesture, and the box is abandoned rather than drawn over a page sliding underneath it. * Mouse and pen are untouched: a plain drag still marquees on contact, and on a fine pointer the Stage still reserves the gesture. The gesture is named where the tool is picked -- "hold, then drag" under the mobile panel's button, and the full sentence in the desktop panel's help text on a coarse pointer. No placement banner: PlacementHint is for armed payloads, not tools. e2e/select-area-touch.e2e.mjs covers both halves (a plain swipe scrolls; a press-and-hold draws the box, catches what is inside it, and does not scroll), plus a tap still deselecting and a mouse still marqueeing without a hold. It fails on the previous code on exactly the two scroll checks. Verified in headless Chromium at 390x844 with CDP touch: the four touch checks and the two mouse checks pass, pinch-to-zoom still zooms with the tool active, and shape-tap / line-tap / word-dblclick / placement-hint / panel-dodge / actions-menu / qr-star / redact-hint-follow / link-click / external-links still pass. NOT verified on WebKit or on a real device -- the preventDefault claim is the part that would differ, and the iOS build needs eyeballing before this is trusted there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AEHtbSEGwEPNcfGjJJSBV2
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.
Fixes the reported problem with Select area on mobile: "my guess would be it's linked to the touchscreen tap and swipe to move up and down on multiple pages" — the guess was right.
The cause
Select area needs a one-finger drag to draw its box. So does scrolling through the document, and the page could only give that gesture to one of them. It gave it to the box outright —
touch-action: noneon every page's Konva Stage — so picking Select area on a phone froze the document. Every swipe drew an empty selection box instead of scrolling, an empty sweep deliberately leaves the tool armed for another try, and there was no way to reach page 4 (or to get out) short of going back to the toolbar and picking a different tool.Measured in a 390×844 touch context, one swipe up:
This is the same mistake the one-shot placement tools made, and it takes the same shape of answer.
The fix
pan-y pinch-zoomwith Select area active, so swiping and pinching work exactly as they do with Select.touch-actionis read once when the finger lands, so it cannot be flipped at hold time. A native non-passivetouchmovelistener claims the gesture withpreventDefaultinstead, which works because the finger has not moved and the scroll has not begun. A move that arrives non-cancelable means the browser kept the gesture, and the box is abandoned rather than drawn over a page sliding underneath it.PlacementHintis for armed payloads, not tools.Testing
npm run test:select-areais new and covers both halves — a plain swipe scrolls; a press-and-hold draws the box, catches what is inside it, and does not scroll — plus a tap still deselecting and a mouse still marqueeing without a hold. It goes red on the previous code on exactly the two scroll checks.Verified in headless Chromium at 390×844 with CDP touch: the four touch checks and the two mouse checks pass, pinch-to-zoom still zooms with the tool active,
tsc -b --noEmitis clean, and shape-tap / line-tap / word-dblclick / placement-hint / panel-dodge / actions-menu / qr-star / redact-hint-follow / link-click / external-links still pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01AEHtbSEGwEPNcfGjJJSBV2
Generated by Claude Code