components icon indicating copy to clipboard operation
components copied to clipboard

bug(cdkDropList): Wrong index for cdkPlaceHolder/cdkDrag after drag/hover other list and going back to original droplist

Open PsychoSpike opened this issue 1 year ago • 2 comments

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

My apologies if this is a stupid use case, I am trying to use multiple droplists as a base for a patience/solitaire card game as a learning project. There are multiple connected droplists where you can only drag the last item, and drop it in the last position of another container. This works amazing.

However, dragging from a cdkDroplist from the right to another cdkDroplist to the left of it and returning to the original list does not put the cdkPlaceHolder in the original index. Dragging from left to right (and returning to the original list) does?!

Not sure is this is an issue or working as intended. I think i understand partially why it happens, but don't understand why it does work from left to right.

Reproduction

StackBlitz link: https://stackblitz.com/~/github.com/PsychoSpike/cdkDropListsSortedToBottom Steps to reproduce:

  1. Pick up an item from the most right list
  2. Drag(not drop) it over a list to the left
  3. Return to the original list

Expected Behavior

The CdkDragPlaceholder and CdkDrag element returns to its original index

Actual Behavior

The CdkDragPlaceholder shows up at the wrong index and the CdkDrag element gets put into index-1 from starting the drag

Environment

  • Angular:
  • CDK/Material:
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):

PsychoSpike avatar Apr 21 '24 15:04 PsychoSpike

If this i not an issue, please elaborate how i can replicate what happens when dragging an item over a right list. For example, when using the middle list, you can mess up the placeholder by going to the left, but if you drag it over the right container, the drag placeholder is back to its original index.

I think i can then maybe correct the index using the DragEnter of the Droplist, however i can't figure it out.

PsychoSpike avatar Apr 21 '24 16:04 PsychoSpike

I don't know if bumping this is a good idea, but i recently (almost) finished this learning project and would like to add the URL to the application itself: testsolitaire

Thank you in advance for your time if you could offer some insights.

PsychoSpike avatar Apr 28 '24 11:04 PsychoSpike