Skip to content
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

fix(cdk/drag-drop): last item not returned at initial index when sorting is disabled #23934

Conversation

crisbeto
Copy link
Member

Fixes a regression caused by #19116 where dragging the last item into another container and returning it back to the initial one would insert the item into the first index of the list, rather than the last one. The issue was caused by the fact that we relied on the item to always be inserted at the end of the list of there is no position reference, but the condition was superseded by the condition that inserts it at the beginning of the list.

Fixes #23865.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Nov 10, 2021
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 10, 2021
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -299,6 +299,16 @@ export class DropListRef<T = any> {
newPositionReference = activeDraggables[newIndex + 1];
}

// If we didn't find a new position reference, it means that either the item didn't start off
// in this container, or that the item request to be inserted at the end of the list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// in this container, or that the item request to be inserted at the end of the list.
// in this container, or that the item requested to be inserted at the end of the list.

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Nov 17, 2021
…ing is disabled

Fixes a regression caused by angular#19116 where dragging the last item into another container and returning it back to the initial one would insert the item into the first index of the list, rather than the last one. The issue was caused by the fact that we relied on the item to always be inserted at the end of the list of there is no position reference, but the condition was superceded by the condition that inserts it at the beginning of the list.

Fixes angular#23865.
@crisbeto crisbeto force-pushed the 23865/drag-drop-last-item-sorting-disabled branch from 2d14ac3 to 05f8dfb Compare November 18, 2021 08:28
@wagnermaciel wagnermaciel merged commit e219008 into angular:master Dec 3, 2021
wagnermaciel pushed a commit that referenced this pull request Dec 3, 2021
…ing is disabled (#23934)

Fixes a regression caused by #19116 where dragging the last item into another container and returning it back to the initial one would insert the item into the first index of the list, rather than the last one. The issue was caused by the fact that we relied on the item to always be inserted at the end of the list of there is no position reference, but the condition was superceded by the condition that inserts it at the beginning of the list.

Fixes #23865.

(cherry picked from commit e219008)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drag and Drop example broken
3 participants