Does cdkDrag suppress native drag and drop events?
See original GitHub issueWhat are you trying to do?
Use native drag and drop events such as dragstart
, dragenter
and dragexit
in conjunction with cdkDrag. Without these it’s hard to build richer behaviours in as well as things like visually highlighting the drop zone.
What troubleshooting steps have you tried?
I have tried attaching these events to both the container list and the individual draggable list items but they don’t seem to fire.
Reproduction
https://components-issue-un5pqw.stackblitz.io
Steps to reproduce:
- Go to the stackblitz
- Try dragging items in the list
- Notice that the ondragstart event doesn’t fire
- Try adding other native drag events and see whether they work - I can’t seem to make them do so
Environment
- Angular: 12.2.9
- CDK/Material: 12.2.9
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
5 Things I wish I knew about the CDK's Drag & Drop
When I first implemented this by hand, I discovered that the native drag and drop capabilities move the image to a new layer...
Read more >Drag and Drop | Angular Material
Emits when the user has moved a new drag item into this container. Emits when the user removes an item from the container...
Read more >Angular CDK Drag and Drop: Cancel drag-action
If you want to disable dragging for a particular drag item, you can do so by setting the cdkDragDisabled input on a cdkDrag...
Read more >Drag and drop multiple cdkDrag elements #13807 - GitHub
Select multiple cdkDrag elements e.g with a checkbox and drag ... dragging under the hood, bcs it require native mouse event and target....
Read more >Drag-and-Drop Isn't a Drag with Angular Material CDK
From uploading files in Dropbox to sorting boards in Trello, drag-and-drop is an increasingly universal part of modern UIs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, if you want free dragging (e.g. like a shortcut on your desktop), you should use
cdkDrag
withoutcdkDropList
.As for terminology, the two main directives are:
cdkDrag
- an element that can be dragged. If it’s inside acdkDropList
, it’ll be treated as a part of the list, otherwise it can be dragged around freely.cdkDropList
- a list that allows forcdkDrag
items to be sorted. Lists can be connected in order to allow items to be transferred.cdkDropList
is similar to jQuery UI sortable.There are some other directives that supplement the two above. See the docs: https://material.angular.io/cdk/drag-drop/overview