bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
22.01k stars 1.97k forks source link

Respect non-element node original positions when reverting on cancel #551

Open guiprav opened 6 years ago

guiprav commented 6 years ago

Fixes #550. All tests pass.

Try dragging "CCC" item below the list. Before this fix, the element gets returned to the end of the container, disregarding the fact that there were non-element nodes after it on drag start. After the fix, it gets returned to its proper position.

I tried writing a test for this issue, but I couldn't figure how to simulate actually dragging elements around, and that's required to trigger the bug. I couldn't find any tests that did dragging (AFAICT). If someone can point me to a test that actually drags elements around, I'll have a look at it and write the test.

Ideally, non-element nodes should be respected while dragging as well, but that might be a bit more difficult (just a bit, I think). I'll give that a shot if there's positive response to this PR.

Thanks!