So i created mat tab group that currently only work for tabs, but sub -tabs have problem that i will show you in gif. Only 1, 2 sub tab can't be drag and dropped on them all other cases are working.
https://gfycat.com/corruptwarmheartedamericanavocet
I tried everything, clear css change css but nothing is working, always event container and previousContainer are same -> that dragged element.
<mat-tab-group vertical flex="1" class="vertical-mat-tab" #matGroupSubTab >
<mat-tab *ngFor = "let subtab of arraySubtabs; let index = index">
<ng-template matTabLabel>
<div class="dropBox" [id]="'list-'+index"
cdkDropList
cdkDragRootElement=".mat-tab-label"
cdkDropListOrientation="vertical"
(cdkDropListDropped)="dropSubTab($event)"
[cdkDropListConnectedTo]="getAllListSubTabConnections(index)">
<div cdkDragBoundary=".mat-tab-labels" cdkDrag>{{ subtab.name }}</div>
</div>
</ng-template>
</mat-tab>
</mat-tab-group>
getAllListSubTabConnections (index) {
const connections = [];
for (let i = 0; i < this.arraySubtabs.length; i++) {
if (i !== index) {
connections.push('list-' + i);
}
}
return connections;
}
dropSubTab (event: CdkDragDrop<string[]>) {
const previousIndex = parseInt(event.previousContainer.id.replace('list-',''), 10);
const newIndex = parseInt(event.container.id.replace('list-',''), 10);
if (!Number.isNaN(previousIndex) && !Number.isNaN(newIndex) &&
previousIndex !== undefined && newIndex !== undefined && previousIndex !== newIndex) {
moveItemInArray(this.arraySubtabs, previousIndex, newIndex);
}
}
Everything is working now.
The problem was that I had the same [id]="'list-'+index" for horizontal and vertical tabs. Why am I so damn stupid?