Angular 7 Drag&Drop nested lists with native CDK

Viewed 2686

I am using native Angular 7 Drag&Drop provided by @angular/cdk/drag-drop.

Basically, I just need to create one sortable list inside another one as in the code below:

<div class="external-list" cdkDropList (cdkDropListDropped)="drop1($event)">
  <div class="external-item" cdkDrag *ngFor="let item of items">
    {{item.header}}
    <div class="internal-list" cdkDropList (cdkDropListDropped)="drop2($event)">
      <div class="internal-item" cdkDrag *ngFor="let row of item.rows">
        {{row}}
      </div>
    </div>
  </div>
</div>

This is a very schematic example just to demonstrate the purpose.

The problem is when I try dragging the inner items outer ones are dragged instead.

How can I solve this without resorting to 3rd-party packages?

1 Answers
Related