angular / angular/components

bug(drag-drop): Item not always restored to initial index when using cdkDropListSortingDisabled on connected lists

Open
#26,360 3 comments 0 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

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Dragging an item from its original drop list to another one then dragging it back to the original drop list isn't always restored to its initial index.

### Reproduction

StackBlitz: https://stackblitz.com/edit/angular-1ra8a1?file=src/app/cdk-drag-drop-disabled-sorting-example.html

Steps to reproduce:
1. Drag any item item from the top container to the bottom one (without dropping) and drag it back to the top container
2. Observer that the item gets re-added at its original index in the top container
3. Drag any item but the first from the bottom container to the top one (without dropping) and drag it back to the bottom container

### Expected Behavior

Item re-added to the bottom container at its original index.

### Actual Behavior

Item re-added to the bottom container at an index lower than its original.

### Environment

- Angular: 15.0.4
- CDK/Material: 15.0.3
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

Contributor guide

Open the contributing guide

Research direction

Start with the reproduction in the linked StackBlitz, particularly src/app/cdk-drag-drop-disabled-sorting-example.html, and verify the index changes when moving items between connected lists without dropping. Trace the CDK drag-drop handling for disabled sorting and confirm completion when an item returns to its original list at its original index.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.