fix(drag-drop): sometimes incorrectly swapping items at the ends of the list #19633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The drop list has some logic that doesn't allow a swap to occur if the items being swapped are the same as the ones in the previous swap and the direction of the user's pointer hasn't changed. This is set up so that we don't trigger a swap for every pixel, if the user's pointer lands on a different item after the previous swap is done.
The above-mentioned logic can be problematic if the user takes an item from the middle, drags it out of the list and then inserts it at the end while dragging upwards. In this case the list won't allow the swap, because the item is the same as the one in the previous swap and the pointer's direction hasn't changed.
These changes resolve the issue by preventing the swap only if the user's pointer landed on the same item after the previous swap was finished.
Fixes #19249.