Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/cdk/drag-drop/sorting/mixed-sort-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ export class MixedSortStrategy implements DropListSortStrategy {
* out automatically.
*/
enter(item: DragRef, pointerX: number, pointerY: number, index?: number): void {
// Remove the item from current set of items first so that it doesn't throw off the indexes
// further down in this method. See https://github.com/angular/components/issues/31505
const currentIndex = this._activeItems.indexOf(item);

if (currentIndex > -1) {
this._activeItems.splice(currentIndex, 1);
}

let enterIndex =
index == null || index < 0
? this._getItemIndexFromPointerPosition(item, pointerX, pointerY)
Expand All @@ -154,11 +162,6 @@ export class MixedSortStrategy implements DropListSortStrategy {
}

const targetItem = this._activeItems[enterIndex] as DragRef | undefined;
const currentIndex = this._activeItems.indexOf(item);

if (currentIndex > -1) {
this._activeItems.splice(currentIndex, 1);
}

if (targetItem && !this._dragDropRegistry.isDragging(targetItem)) {
this._activeItems.splice(enterIndex, 0, item);
Expand Down
Loading