Skip to content

Commit

Permalink
Prevent HTML Drag and Drop events while sensor is active
Browse files Browse the repository at this point in the history
  • Loading branch information
Clauderic Demers committed Nov 14, 2021
1 parent a3b7192 commit d973cc6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/prevent-html-drag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/core': patch
---

Sensors that extend the `AbstractPointerSensor` now prevent [HTML Drag and Drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API) events from being triggered while the sensor is activated.
1 change: 1 addition & 0 deletions packages/core/src/sensors/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export enum EventName {
Click = 'click',
DragStart = 'dragstart',
Keydown = 'keydown',
ContextMenu = 'contextmenu',
Resize = 'resize',
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/sensors/pointer/AbstractPointerSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class AbstractPointerSensor implements SensorInstance {
this.listeners.add(events.move.name, this.handleMove, {passive: false});
this.listeners.add(events.end.name, this.handleEnd);
this.windowListeners.add(EventName.Resize, this.handleCancel);
this.windowListeners.add(EventName.DragStart, preventDefault);
this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);
this.windowListeners.add(EventName.ContextMenu, preventDefault);
this.documentListeners.add(EventName.Keydown, this.handleKeydown);
Expand Down

0 comments on commit d973cc6

Please sign in to comment.