Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Can't cancel swap once an item has been hovered over #1866

Open
yjukaku opened this issue Jul 15, 2020 · 12 comments
Open

[bug] Can't cancel swap once an item has been hovered over #1866

yjukaku opened this issue Jul 15, 2020 · 12 comments
Labels
enhancement Quality of life changes to existing features good first issue A great place for new contributions Swap Relating to the Swap plugin

Comments

@yjukaku
Copy link

yjukaku commented Jul 15, 2020

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:

  1. Go to https://sortablejs.github.io/Sortable/#swap
  2. 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.
  3. 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!

@wangdanting
Copy link

+1

@waynevanson waynevanson added Swap Relating to the Swap plugin enhancement Quality of life changes to existing features labels Aug 31, 2020
@waynevanson
Copy link
Contributor

I agree that your description is how it intuitively should work.

Accepting PR's!

@waynevanson waynevanson added status:accepting-pulls good first issue A great place for new contributions labels Aug 31, 2020
@CaptainYouz
Copy link

hi everyone!
i have the exact same problem :)
any news on this one ?

@yjukaku did you find any workaround ?

@yjukaku
Copy link
Author

yjukaku commented Oct 27, 2020

I did not.

JoakimFFCG added a commit to JoakimFFCG/sortablejs that referenced this issue Nov 30, 2020
JoakimFFCG added a commit to JoakimFFCG/sortablejs that referenced this issue Nov 30, 2020
@JoakimFFCG
Copy link

I've made a fix here: JoakimFFCG@90c4f89#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.

@Danieliverant
Copy link

Danieliverant commented Apr 1, 2021

Any news on that?

@oleksiisolomko
Copy link

any updates?

@robinpoort
Copy link

Got the same problem here, any updates on the great fix of @JoakimFFCG ? :)

kishtra added a commit to kishtra/Sortable that referenced this issue May 30, 2022
Swap plugin now cancels the swap when dragging an element over invalid drop targets.
@wChenonly
Copy link

Is this out of progress?

@kishtra
Copy link

kishtra commented Sep 16, 2022

@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.

@jambortamas
Copy link

jambortamas commented Oct 22, 2022

Any updates about this issue?

This was referenced Jan 9, 2024
@joelacus
Copy link

Are there any more updates for this? The issue still persists in version 1.15.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Quality of life changes to existing features good first issue A great place for new contributions Swap Relating to the Swap plugin
Projects
None yet
Development

No branches or pull requests