angular / angular/components

cdkDropList: event.previousIndex does not update on second move

Open
#14,056 12 comments 7 reactions 0 assignees View on GitHub
area: cdk/drag-drop P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Bug, feature request, or proposal:
When you drag and drop a row for the second time, the previousIndex is still the same as the initial value.

#### What is the expected behavior?
previousIndex should reflect the items position when the dragging is started.

#### What is the current behavior?
It stays the same as the initial value, so neither sorting nor moving works as intended. It only works the first time moving the row, after that it will always jump back/move another item.

#### What are the steps to reproduce?
Stackblitz here:
https://stackblitz.com/edit/table-drag-n-drop

#### Is there anything else we should know?
I am using cdkDropList together with Material Table.

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and the cdkDropList event handling used with Material Table. Reproduce two successive moves and inspect whether previousIndex reflects the position at drag start. Done means sorting and moving continue to work correctly on subsequent moves.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.