Skip to content

Drag and Drop causes incorrect ordering - in one edge case #12388

Closed
@MrJoshuaT

Description

@MrJoshuaT

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When reordering items, they should reorder correctly

What is the current behavior?

Some edge cases will cause incorrect rendering of items in the DOM. The data inside the cdk-container is correct though.

What are the steps to reproduce?

StackBlitz example: https://stackblitz.com/edit/angular-e4nuja?file=app%2Fautocomplete-overview-example.html

  1. Drag the last item to the first position, this will cause the first item to become the second (correct - 0,1,2,3 order).
  2. Drag the now second item (that was first) to the last position, this will cause an order of 1,2,0,3.

As a note: after doing the steps above, adding a console.log, and dragging the third item to the first (where it should be) will show the previousIndex and currentIndex as the same value - 0.

What is the use-case or motivation for changing an existing behavior?

Can't seem to always show correct order - in one edge cases where dragging last to first and second to last.

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

Latest as of time of writing.
Material = 6.4.1
Cdk = 6.4.1
CdkExperimental = 6.4.1

Is there anything else we should know?

This seems to be the only edge case I've been able to find, even with help from our internal testers.

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaround

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions