drag and drop: *cdkDragPreview not working when using an existing component
See original GitHub issueWhat is the expected behavior?
When I set a custom preview with a component, the component is used for the preview.
What is the current behavior?
The component is not showing as the preview. The preview is empty.
What are the steps to reproduce?
Create a drag item, for example.
<div cdkDrag>
my Item
<app-room [room]="room" *cdkDragPreview></app-room>
</div>
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7 Material: 7.3.6
Is there anything else we should know?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
cdk-drag-preview not applying styles - css - Stack Overflow
I want the preview to look exactly like the element being dragged, but the preview is only showing the text content of the...
Read more >Drag and Drop | Angular Material
Start by importing DragDropModule into the NgModule where you want to use drag-and-drop features. You can now add the cdkDrag directive to elements...
Read more >Exploring Drag and Drop with the new Angular Material CDK
Now that we've imported the module we can create our first draggable component by using the cdkDrag directive.
Read more >Getting to Know the Angular CDK Drag and Drop Feature
In this article, we'll learn how to use the drag and drop feature. If you want to learn about virtual scrolling, you can...
Read more >Angular Material Drag and Drop – Strengths and Limitations
Getting started with Material Drag and Drop is very simple. In an existing angular application with the CDK installed, ...
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
Closing, I found my bug. Sorry for wasting your time. And thank you for suggesting a stackblitz, it helped me think this straight.
I’m not sure this can help other people, but here it goes anyway: The component I’m using as preview had this *ngIf:
*ngIf="!(isDragging$ | async) || !(isSelected$ | async)"
We have a multi-select thing where then you drag all of them. Which of course the one you are dragging is Selected, and you are in dragging mode
I had to add a isPreview in it:
*ngIf="isPreview || !(isDragging$ | async) || !(isSelected$ | async)"
So, really silly thing completely unrelated to drag and drop, but sometimes you start looking at the wrong side of it and you fall in a rabbit hole I guess.