Skip to content

Drag and Drop list ordering issue #14873

@regocziTamas

Description

@regocziTamas

What is the expected behavior?

I am trying to reproduce the simple drag and drop list ordering example from here: https://material.angular.io/cdk/drag-drop/overview

What is the current behavior?

However, the dragged item always snaps back to its original place. The ordering animation is showing. The event shows that the previous and the current index are always 0.
https://i.imgur.com/1RkV6MT.gifv
https://i.imgur.com/k4wMbt3.gifv

What are the steps to reproduce?

The drop listener and the test data:

strings = ["dsfs","fgjdf","ghama","jéép"];
drop(event: CdkDragDrop<String[]>) {
    console.log(event);
    moveItemInArray(this.strings, event.previousIndex, event.currentIndex);
}

The HTML:

<div cdkDropList *ngFor="let string of strings" [cdkDropListData]="strings" (cdkDropListDropped)="drop($event)">
    <mat-card cdkDrag [cdkDragData]="string">{{string}}</mat-card>
</div>

The CSS is copy-paste from the tutorial

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

Angular: 6.2.1
Material: 7.2.1
OS: Ubuntu 16.04
TypeScript: 3.2.2
Chrome: 65.0.3325.146

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/drag-drop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions