question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(@angular/cdk): dragStart event completely blocked within ```cdkDrag``` element

See original GitHub issue

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

13.2.3

Description

Inside a Angular’s cdkDropList I use another third party library for sorting a grid (display:flex; flex-wrap:wrap) with Drag’n’Drop. After upgrading Angular’s CDK from version 13.2.3 to 13.2.4 this third party component stopped working.

After some detailed research I’ve found the root cause in cdk/drag-drop/drag-ref.ts:

image

With this added line you’ll break the dragstart event, what makes it impossible to use any other drag’n’drop functionality within CDK’s Drag’n’Drop functionality.

Reproduction

No steps to reproduce.

Expected Behavior

The dragstart event should still be fired within an cdkDrag element.

Actual Behavior

dragstart event is completely blocked with event.preventDefault(), which makes it absolutely impossible to use Angular’s Drag’n’Drop functionality with custom or even native Drag’n’Drop functionality inside.

Environment

  • Angular: 13.2.4
  • CDK/Material: 13.2.4
  • Browser(s): Google Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Mar 12, 2022

That makes sense, it’s how the mousedown/touchstart event works as well. I’ve sent out #24581 to fix it.

0reactions
angular-automatic-lock-bot[bot]commented, Apr 12, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular/cdk simple drag not working for div with ngFor
I need to make an item draggable with angular-cdk. I have imported the DragDropModule in the app module.
Read more >
Drag & Drop Angular CDK - Medium
Let's focus on reordering the to-do items within the same list, first. We can do that by listening to the cdkDropListDropped event on...
Read more >
Drag and Drop | Angular Material
Adding cdkDropList around a set of cdkDrag elements groups the draggables into a reorderable collection. Items will automatically rearrange as an element moves....
Read more >
UNPKG - @angular/cdk
@angular/cdk/bundles/cdk-drag-drop.umd.min.js.map. Version: ... nativeElement)) {\n throw Error('Draggable element is not inside of the node passed into ...
Read more >
Angular 14 Drag and Drop Tutorial with Material Library
The angular/cdk/drag-drop module provides access for creating a drag and ... method for dragging and dropping HTML element in Angular app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found