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.

[CdkDrag] Dragging the last item will break the structure of the list.

See original GitHub issue

Bug, feature request, or proposal: Bug

What is the expected behavior?

List structure remains identical after drag/drop

What is the current behavior?

List structure breaks when dragging the last item in a list where the drop container is not the direct father (and when not using NGFOR)

What are the steps to reproduce?

https://stackblitz.com/edit/angular-9xpwbj

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

7.0.4

Is there anything else we should know?

This bug is in the cleanup routine of the CdkDrag compoment, if there is no “nextSibling”, i.e. last item in drag container, and the drop container is not the father (direct parent) of the list it will append the dragged item to the container which is not the direct list owner.

This will not happend when using *ngFor because *ngFor will add a comment element after each list item which causes CdkDrag to think it’s not the last sibling.


I also think that the fact it doesn’t happen in*ngFor is a bug, the nextSibling should reflect the next draggable item but the code queries for any node… instead of element.nextSibling it should probably be element.nextElementSibling


Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Nov 15, 2018

Sure.

0reactions
shlomiassafcommented, Nov 15, 2018

For anyone facing this issue, until resolved, the following gist contains a workaround for all issues in this PR + the ability to lazy bind a CdkDrag and a CdkDropList (i.e. out of scope binding between CdkDrag and CdkDropList as described in #14099)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't drop element in previously hidden cdkDropList
I am trying to drag a cdkDrag item into a cdkDropList found in a subtree of a Tree component. I hover over the...
Read more >
UNPKG - @angular/cdk
src/cdk/drag-drop/directives/drop-list-group.ts","../. ... */\n _dragRef: DragRef<CdkDrag<T>>;\n\n /** Elements that can be used to drag the draggable item.
Read more >
Dragging a draggable element out of a scrollable div - GSAP
I 'm buidling a scrollable bar at the top of the page (which kan be hidden/shown). That bar contains draggable elements that will...
Read more >
Row Dragging - JavaScript Data Grid
When you drag an item that is not selected while other items are selected, only the unselected item will be dragged. Example: Row...
Read more >
TOP 5 Angular Drag And Drop Libraries - Morioh
The @angular/cdk/drag-drop module provides you with a way to easily and declaratively cr. ... I would like to share with you python list...
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