Skip to content

fix(cdk/drag-drop): incorrect index when returning item in mixed list #31592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

crisbeto
Copy link
Member

When an item enters a mixed orientation list, we were figuring out its index, removing the item from the list and then trying to insert it in that index. The problem is that by removing the item, we might have changed the array in a way where the index isn't valid anymore.

These changes resolve the issue by removing the item first before making any index calculations.

Fixes #31505.

When an item enters a mixed orientation list, we were figuring out its index, removing the item from the list and then trying to insert it in that index. The problem is that by removing the item, we might have changed the array in a way where the index isn't valid anymore.

These changes resolve the issue by removing the item first before making any index calculations.

Fixes angular#31505.
@crisbeto crisbeto requested a review from a team as a code owner July 24, 2025 08:22
@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Jul 24, 2025
@crisbeto crisbeto requested review from adolgachev and ok7sai and removed request for a team July 24, 2025 08:22
@crisbeto crisbeto removed request for adolgachev and ok7sai July 24, 2025 14:24
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jul 24, 2025
@crisbeto crisbeto merged commit 88d4ffd into angular:main Jul 24, 2025
28 of 29 checks passed
@crisbeto
Copy link
Member Author

The changes were merged into the following branches: main, 20.1.x

crisbeto added a commit that referenced this pull request Jul 24, 2025
…#31592)

When an item enters a mixed orientation list, we were figuring out its index, removing the item from the list and then trying to insert it in that index. The problem is that by removing the item, we might have changed the array in a way where the index isn't valid anymore.

These changes resolve the issue by removing the item first before making any index calculations.

Fixes #31505.

(cherry picked from commit 88d4ffd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/drag-drop target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(CdkDragDrop): cdkDropListOrientation="mixed" reports wrong currentIndex
2 participants