From de6a2777863a4e91973dbce9751e20b1fe493934 Mon Sep 17 00:00:00 2001 From: Martin Pengelly-Phillips Date: Wed, 2 Nov 2022 15:18:56 +1100 Subject: [PATCH] Only accept primary button for activating drag. Fix an issue on some platforms where the contextmenu shows on right-click and intercepts the pointerup events that would cancel the drag, leading to a sticky unintended drag. For #30 --- CHANGELOG.md | 9 +++++++++ src/create-pointer-sensor.ts | 2 ++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c32d624..f4b617f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [Unreleased] + +### Fixed + +- Only accept primary button (left-click) for activating drag with default + pointer sensor. Fix an issue on some platforms where the contextmenu shows on + right-click and intercepts the pointerup events that would cancel the drag, + leading to a sticky unintended drag. + ## [0.7.2] - 2022-10-07 ### Fixed diff --git a/src/create-pointer-sensor.ts b/src/create-pointer-sensor.ts index fc0c94f..3696983 100644 --- a/src/create-pointer-sensor.ts +++ b/src/create-pointer-sensor.ts @@ -40,6 +40,8 @@ const createPointerSensor = (id: Id = "pointer-sensor"): void => { let activationDraggableId: Id | null = null; const attach: SensorActivator<"pointerdown"> = (event, draggableId) => { + if (event.button !== 0) return; + document.addEventListener("pointermove", onPointerMove); document.addEventListener("pointerup", onPointerUp);