Files
TREK/client/src/utils/touchDragPolyfill.ts
T
Maurice edea67ff7e fix(planner): let tablets drag places into the day plan (#1616)
Dragging a place from the right pane to the left one did nothing on an
iPad or a Samsung tablet — the row was selected as text instead. Phones
never reach this layout, they get the mobile shell below md, so the coarse
pointer check in dragDisabled was only ever switching tablets off.

It was also doing that for a reason that had gone away. What swallowed the
scroll gesture in #1432 was the drag-drop-touch polyfill, and that has been
confined to hybrid laptops since. Width is the gate that still means
something: below lg the plan and the places are separate tabs, so there is
nothing to drag between.

So touch is no longer a reason to disable the drag, and the planner arms
the long-press bridge instead where the pointer is coarse. Rows get
-webkit-touch-callout and user-select off there too, otherwise the press
that starts the drag brings up the selection first. The isTouch prop had no
other use and is gone, along with a comment claiming arrow reorder buttons
take over on touch — there are none.
2026-07-29 19:15:57 +02:00

20 lines
1.1 KiB
TypeScript

/**
* `drag-drop-touch` bridges native HTML5 drag-and-drop to touch so the planner's
* place/day reordering works on touch input (#1265). It installs document-level touch
* listeners on import and, on every single-finger touch, records the touchend time and
* synthesises a `dblclick` when the next touch starts within 500 ms. On the map that
* dblclick fires the default double-click-zoom, so two quick one-finger pans zoomed
* instead of panning (#1440).
*
* The hybrid laptop is the only device class left with a job for it: a mouse as the
* primary pointer, with a touchscreen also available. Loading it anywhere else re-arms
* the very gesture hijack #1432 removed, and drags the #1440 phantom-dblclick along
* with it. Coarse-pointer devices get touchDragBridge instead, which waits out a long
* press before it claims a gesture and so leaves scrolling alone (#1616).
*/
export function maybeInstallTouchDragPolyfill(): Promise<unknown> | void {
if (typeof window === 'undefined') return
if (!window.matchMedia('(pointer: fine) and (any-pointer: coarse)').matches) return
return import('drag-drop-touch')
}