cdkDropListSortingDisabled
option only works when moving items within the same container. If you move from one container to another then Angular sorts position of blocks:
this._itemPositions = this._activeDraggables.map(drag => {
const elementToMeasure = drag.getVisibleElement();
return {drag, offset: 0, clientRect: getMutableClientRect(elementToMeasure)};
}).sort((a, b) => {
return isHorizontal ? a.clientRect.left - b.clientRect.left :
a.clientRect.top - b.clientRect.top;
});
Since you didn't provide orientation and default is vertical then it is sorted by top
position.
The top box event.currentIndex
is always 0 because you use absolute positioning and placeholder is always at the top.
Try adding the following style to see where the placeholder is displayed:
.cdk-drag-placeholder {
opacity: 1;
background: red;
}

To fix it you can calculate currentIndex
by yourself, e.g. like this:
const isWithinSameContainer = event.previousContainer === event.container;
let toIndex = event.currentIndex;
if (event.container.sortingDisabled) {
const arr = event.container.data.sort((a, b) => a.top - b.top);
const targetIndex = arr.findIndex(item => item.top > top);
toIndex =
targetIndex === -1
? isWithinSameContainer
? arr.length - 1
: arr.length
: targetIndex;
}
const item = event.previousContainer.data[event.previousIndex];
item.top = top;
item.left = left;
if (isWithinSameContainer) {
moveItemInArray(event.container.data, event.previousIndex, toIndex);
} else {
transferArrayItem(
event.previousContainer.data,
event.container.data,
event.previousIndex,
toIndex
);
}
Forked Stackblitz