@jsenv/dom 0.17.4 → 0.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +15 -1
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -8802,7 +8802,7 @@ const createDragGestureController = (options = {}) => {
8802
8802
  };
8803
8803
  dragGestureController.grab = grab;
8804
8804
  const initDragByPointer = (grabEvent, dragOptions, initializer) => {
8805
- if (grabEvent.button !== undefined && grabEvent.button !== 0) {
8805
+ if (!isPrimaryButtonEvent(grabEvent)) {
8806
8806
  return null;
8807
8807
  }
8808
8808
  const target = grabEvent.target;
@@ -8898,12 +8898,22 @@ const createDragGestureController = (options = {}) => {
8898
8898
  dragGestureController.grabViaPointer = grabViaPointer;
8899
8899
  return dragGestureController;
8900
8900
  };
8901
+
8902
+ // Only the primary button drags: a right click (or any secondary button) opens
8903
+ // a context menu, it never grabs anything.
8904
+ const isPrimaryButtonEvent = event => event.button === undefined || event.button === 0;
8901
8905
  const dragAfterThreshold = (grabEvent, dragGestureInitializer, threshold) => {
8906
+ if (!isPrimaryButtonEvent(grabEvent)) {
8907
+ return;
8908
+ }
8902
8909
  const target = grabEvent.target;
8903
8910
  const isDedicatedHandle = target.closest && target.closest("[data-drag-handle]");
8904
8911
  if (isDedicatedHandle) {
8905
8912
  // Element is dedicated to drag — skip the threshold and start immediately.
8906
8913
  const dragGesture = dragGestureInitializer();
8914
+ if (!dragGesture) {
8915
+ return;
8916
+ }
8907
8917
  dragGesture.dragViaPointer(grabEvent);
8908
8918
  return;
8909
8919
  }
@@ -11041,6 +11051,10 @@ const startDragToReorder = (event, {
11041
11051
  if (event.target.closest && event.target.closest("[data-drag-ignore]")) {
11042
11052
  return undefined;
11043
11053
  }
11054
+ // A secondary button (right click and friends) is a context menu, not a grab.
11055
+ if (!isPrimaryButtonEvent(event)) {
11056
+ return undefined;
11057
+ }
11044
11058
  event.preventDefault();
11045
11059
  return dragAfterThreshold(event, () => {
11046
11060
  const cloneWrapper = createDragClone(draggedElement, event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.4",
3
+ "version": "0.17.5",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {