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.

feat(drag-drop): prevent a item be removed when it into another container

See original GitHub issue

Feature Description

CDK(V9) provide [cdkDropListEnterPredicate] to prevent a item into another container, provide (cdkDropListDropped) to determine how to do when user drop the item.

I found when user drag the item into another container but not to release, the item is removed in origin container. When I release it, I didn’t add (cdkDropListDropped), so the item is recovered. But what I want is the item can into another container but not to be removed in any time.

In summary, can you provide (cdkDragLeaved) to determine how to deal with the item when the item into another container?

Use Case

Just imaging you are ordering foods from menu in the restaurant. You need to drag the food into your shopping cart. But the item of the menu should’t be removed. image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
devversioncommented, Aug 7, 2020

Hi @Mr-Eve. great issue! thanks. I think what you are trying to achieve should be partially possible already by just not using the move or transfer utilities the drag-drop provides, but rather by “copying” the element. For example:

    if (event.previousContainer.id === 'menu') {
      event.container.data.splice(event.currentIndex, 0,
        event.previousContainer.data[event.previousIndex]);
    }

The only problem I see here is that the drag placeholder from the menu list is temporarily removed when the item is being dragged over the Shopping cart drop list. cc. @crisbeto

3reactions
andreElricocommented, Aug 17, 2020

@Mr-Eve is what you want a copy feature? something like here?

https://stackblitz.com/edit/angular-krmecd (from #13906)

Check https://github.com/angular/components/issues/13906

  • If thats what you want, close this one and put a thumbs up on issue #13906
  • There are also some workarounds provided.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular drag and drop: Items should not remove from ...
Now, I am trying to not to remove a dropped item from a container, but it should be dropped into another container. enter...
Read more >
Drag and Drop | Angular Material
There are cases where draggable items can be dragged out of one list into another, however the user shouldn't be able to sort...
Read more >
Drag and Drop | Angular Material
Emits when the user removes an item from the container by dragging it into another container. lockAxis: 'x' | 'y'. Locks the position...
Read more >
Minecraft invisible block command - Seba Online
Mar 02, 2019 · 13 Command Blocks Unlike most of the other entries on this list, command blocks are not actual items that...
Read more >
ng2-dragula | Simple drag and drop with ... - Valor Software
By default, dropping an element outside of any known containers will keep the element in the last place it went over. You can...
Read more >

github_iconTop Related Medium Post

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