mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 14:54:49 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user