Skip to content

Commit da302d2

Browse files
authored
fix(cdk/drag-drop): make sure event is cancelable before calling "preventDefault" (angular#28825)
If you set a value for `dragStartThreshold` greater than 0, it will throw console errors saying: "[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted."
1 parent 2b49d8c commit da302d2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cdk/drag-drop/drag-ref.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ export class DragRef<T = any> {
672672
if (!container || (!container.isDragging() && !container.isReceiving())) {
673673
// Prevent the default action as soon as the dragging sequence is considered as
674674
// "started" since waiting for the next event can allow the device to begin scrolling.
675-
event.preventDefault();
675+
if (event.cancelable) {
676+
event.preventDefault();
677+
}
676678
this._hasStartedDragging = true;
677679
this._ngZone.run(() => this._startDragSequence(event));
678680
}
@@ -684,7 +686,9 @@ export class DragRef<T = any> {
684686
// We prevent the default action down here so that we know that dragging has started. This is
685687
// important for touch devices where doing this too early can unnecessarily block scrolling,
686688
// if there's a dragging delay.
687-
event.preventDefault();
689+
if (event.cancelable) {
690+
event.preventDefault();
691+
}
688692

689693
const constrainedPointerPosition = this._getConstrainedPointerPosition(pointerPosition);
690694
this._hasMoved = true;

0 commit comments

Comments
 (0)