Fix: cancel native dragstart on touch devices to enforce hold delay

The sections have draggable="true" which triggers native HTML5 drag
on touch with zero delay, bypassing our 1000ms hold-to-drag logic
entirely. This was most noticeable with collapsed sections where a
brief touch-and-drag instantly reordered them. Now native dragstart
is cancelled on touch devices, forcing all touch reordering through
the hold delay path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
juan
2026-03-22 23:27:00 -07:00
parent 573745af78
commit fbcc261c9c

View File

@@ -22,12 +22,22 @@ export default class extends Controller {
// ===== Mouse Drag Events =====
dragStart(event) {
// On touch devices, cancel native drag — use touch events with hold delay instead
if (this.isTouchDevice()) {
event.preventDefault();
return;
}
this.draggedElement = event.currentTarget;
this.draggedElement.classList.add("opacity-50");
this.draggedElement.setAttribute("aria-grabbed", "true");
event.dataTransfer.effectAllowed = "move";
}
isTouchDevice() {
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
}
dragEnd(event) {
event.currentTarget.classList.remove("opacity-50");
event.currentTarget.setAttribute("aria-grabbed", "false");