mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 14:54:49 +00:00
Fix: use interaction state instead of device capability for drag guard
isTouchDevice() blocked mouse/trackpad drag on touch-capable laptops (e.g. Windows with touchscreen). Now checks if a touch interaction is actually in progress instead. Also adds touchcancel binding to clean up hold timer state when the OS interrupts a touch (notifications, palm rejection, etc). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,8 +22,10 @@ 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()) {
|
||||
// If a touch interaction is in progress, cancel native drag —
|
||||
// use touch events with hold delay instead.
|
||||
// This avoids blocking mouse/trackpad drag on touch-capable laptops.
|
||||
if (this.isTouching || this.pendingSection) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
@@ -34,10 +36,6 @@ export default class extends Controller {
|
||||
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