Skip to content

Commit

Permalink
Only prevent default/propagation if not idle
Browse files Browse the repository at this point in the history
  • Loading branch information
clauderic committed Jan 26, 2025
1 parent 3312dcf commit e6a8e01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-interactive-elements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dnd-kit/dom': patch
---

Fix a bug with `event.preventDefault()` and `event.stopPropagation()` being called on pointer up even if there was no drag operation in progress, which would prevent interactive elements such as buttons from being clicked.
8 changes: 4 additions & 4 deletions packages/dom/src/core/sensors/pointer/PointerSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ export class PointerSensor extends Sensor<
}

private handlePointerUp(event: PointerEvent) {
// Prevent the default behaviour of the event
event.preventDefault();
event.stopPropagation();

// End the drag and drop operation
const {status} = this.manager.dragOperation;

if (!status.idle) {
// Prevent the default behaviour of the event
event.preventDefault();
event.stopPropagation();

const canceled = !status.initialized;
this.manager.actions.stop({canceled});
}
Expand Down

0 comments on commit e6a8e01

Please sign in to comment.