angular / angular/components

Drag&Drop Drop List Dynamic Preview

Open
#16,769 7 comments 2 reactions 0 assignees View on GitHub
area: cdk/drag-drop feature P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### What are you trying to do?

I want to be able to change the drag and drop preview depending on which container you're dropping into.

In my stackblitz I have three different containers. The first and third one have regular drag and drop previews, but the second one I'd like to customize the drag and drop preview. Using
``` ``` works when dragging elements from the second container, but I'd like the preview to be dynamic depending on where you're dropping it.

For example, if you grab an item from the first container and drag it over the second, I'd like the preview to be the image. But it you drag that same item over the third, it should switch back to the regular preview.

#### What troubleshooting steps have you tried?

I've tried to manually do it using cdkDragDropEntered and cdkDragDropExited events but it did not work as expected. Especially with the differences in the width of the previews.

#### Reproduction

https://stackblitz.com/edit/angular-suzb2h

#### Environment

- Angular: latest
- CDK/Material: latest
- Browser(s): All
- Operating System (e.g. Windows, macOS, Ubuntu): All

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and the Angular CDK drag-and-drop preview behavior. Review how cdkDragPreview, cdkDragDropEntered, and cdkDragDropExited are used in the reproduction, then determine how the preview should change between the three containers. Done means the preview switches reliably when entering and leaving each container without incorrect sizing.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.