Sortable
Sortable copied to clipboard
[bug] Can't cancel swap once an item has been hovered over
Describe the bug
When using the Swap plugin, it's impossible to cancel a swap once the swap threshold has been met for an item. You can't drag the item back to its original place to prevent a swap. This happens with or without the revertOnSpill: true
option.
To Reproduce Steps to reproduce the behavior:
- Go to https://sortablejs.github.io/Sortable/#swap
- Drag "Item 1" to hover over "Item 2", triggering Item 2 to get highlighted. Don't drop "Item 1", but instead try to prevent a swap by moving Item 1 back to its original place.
- See: It's not possible to prevent a swap.
Expected behavior
Dragging Item 1 back to its original place, or off of the list, should deactivate the swap.
Information
Sortable.version == 1.10.2
I didn't include a code sandbox since it's visible with Sortable.js's own Github site.
Thank you so much for your work on this library!
+1
I agree that your description is how it intuitively should work.
Accepting PR's!
hi everyone! i have the exact same problem :) any news on this one ?
@yjukaku did you find any workaround ?
I did not.
I've made a fix here: https://github.com/JoakimFFCG/sortablejs/commit/90c4f894b88a6b8b89751f0eeb77333fd6111485#diff-b4ffb7cc6e458fc5b1fca6d2ee32068db651d86a4b1bf5df9e411bcb10d2be40
Here is a demo: https://jsbin.com/zefoloboyi/edit?html,js,output
There have been a lot of changes in the master branch since 1.10.2 and when I compiled the source in the master branch myself, the swap plugin appeared to be broken (as in, the swap option didn't alter the behaviour at all; items were sorted normally). So because I didn't have time to fix that as well, I based this fix on the 1.10.2 release tag. But, because there isn't any 1.10.X branch to merge this to, that means I can't make a PR, @waynevanson
Problem details The cause of this problem was that all logic that determines what other element to swap with were inside the dragOverValid event function. However, that event is only fired when hovering over another swappable element. I solved it by moving some logic to the dragOver event instead.
Any news on that?
any updates?
Got the same problem here, any updates on the great fix of @JoakimFFCG ? :)
Is this out of progress?
@wChenonly I made a PR that seems to fix the issue: #2164 Probably needs a little bit more work; just waiting for a response from maintainers or anybody that sees an issue with it.
Any updates about this issue?
Are there any more updates for this? The issue still persists in version 1.15.2.