Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cdk/drag-drop): make sure event is cancelable before calling "preventDefault" #28825

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cdk/drag-drop/drag-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,9 @@ export class DragRef<T = any> {
if (!container || (!container.isDragging() && !container.isReceiving())) {
// Prevent the default action as soon as the dragging sequence is considered as
// "started" since waiting for the next event can allow the device to begin scrolling.
event.preventDefault();
if (event.cancelable) {
event.preventDefault();
}
this._hasStartedDragging = true;
this._ngZone.run(() => this._startDragSequence(event));
}
Expand All @@ -684,7 +686,9 @@ export class DragRef<T = any> {
// We prevent the default action down here so that we know that dragging has started. This is
// important for touch devices where doing this too early can unnecessarily block scrolling,
// if there's a dragging delay.
event.preventDefault();
if (event.cancelable) {
event.preventDefault();
}

const constrainedPointerPosition = this._getConstrainedPointerPosition(pointerPosition);
this._hasMoved = true;
Expand Down