Shopify / draggable

The JavaScript Drag & Drop library your grandparents warned you about.
https://shopify.github.io/draggable
MIT License
17.96k stars 1.09k forks source link

swapAnimate plugin bug when placing items into an empty container #114

Open madebyaaron opened 6 years ago

madebyaaron commented 6 years ago

Issue: The following error is received when placing a draggable item into an empty container:

screen shot 2018-01-10 at 21 14 00

screen shot 2018-01-10 at 21 13 40

Steps to reproduce:

  1. Init sortable with swapAnimate plugin enabled on multiple containers (e.g 2 kanban lanes)
  2. Drag an item from one lane into the other (empty) lane

p.s I'm using chrome on macos

haoliangwu commented 6 years ago

meet the same problem but I think the bug itself was not due to swapAnimate plugin, the root cause of this behavior is the Sortable shouldn't trigger sorted event when the source element was moved to an empty draggable container instance.

Hope for help. : )

tsov commented 6 years ago

@madebyaaron thanks for reporting! It's an issue with the SwapAnimation plugin, it always assumes that two draggable elements get swapped (top/bottom).

The plugin still comes with limitations, but there are future plans for the plugin:

@haoliangwu Just out of curiosity, why do you think Sortable shouldn't trigger the sorted event if moved into an empty container? It technically gets sorted.

haoliangwu commented 6 years ago

@tsov, uh.., maybe we thought this issue from different angles and I am wrong

but I thought the sort and sorted events should be triggered when the source and over elements were into the same container. Even though the events can be triggered when we drag elements between different containers, if the the overContainer is empty, drag source element to it didn't do any sort business with any over elements, because the over element is null, that's why swapAnimation plugin throw undefined error during its own animation logic.

Sorry for my poor english, wish you can understand my meaning. :)