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

Click triggering - Any control over that? #1184

Closed
renebrain opened this issue Sep 25, 2017 · 7 comments
Closed

Click triggering - Any control over that? #1184

renebrain opened this issue Sep 25, 2017 · 7 comments

Comments

@renebrain
Copy link

The Sortable has a weird behaviour when you try to sort including links or any click events inside of the sortable element. when you drag the item and sort it somewhere else than everything is fine. But when you for example try to sort it but put it back to its original position, he drops the item on and lets the click bubble through. This triggers the elements inside of it, when you where dragging them there. Also just clicking on the sortable item is always triggering the sortable an he picks it up and immediately drops it. shouldn't he just ignore the click and let the click go through? i presume there are certain threshold checks missing in the library to make the click behaviour more controllable inside of the library.

Is it possible to have more control over that?

@renebrain
Copy link
Author

I presume there is nothing then?

@gschnall
Copy link

gschnall commented Dec 11, 2017

@renebrain I see the same issues and, while there are ways of solving both, it gets tricky.

  • To fix your first issue, simply remove the href from the link within the onStart method. You'll want to save it to a variable first before removing it. Then, onEnd add the href attribute back to the element with the saved value.

Here's how it might look

onStart: function (e) {
   var link = e.item.children[0]; // This assumes your a element is the first child of your li element
   this._url = link.href;
   link.removeAttribute("href");  
 },
onEnd: function (e) {
   var link = e.item.children[0];
   setTimeout(function () {
     link.setAttribute("href", this._url);  
   }.bind(this),1);
 },
  • fallbackTolerance is supposed to prevent the second issue you mention; regarding immediately dragging an element. However, this doesn't work for me. Even when setting fallbackTolerance to 1, the drag suffers a 3 second delay. I find it only works consistently if I click, hold down the mouse for 3 seconds, and then drag. Does anyone else experience this same issue?

@getiaotiao
Copy link

hello,when the draggable item which is binded click event, i drag it nearby,then mouseup the mouse,the item back to the origin place,then the click event triggered,i don't need triggering the click event,how does i do?

@owen-m1
Copy link
Member

owen-m1 commented Jan 15, 2019

Fixed in 1.8.0

@DenysPoliarush
Copy link

It still doesn't work in Firefox.
When I drag the item which is bound click event, the click event always triggered.

@taekimm
Copy link

taekimm commented Mar 30, 2021

Still seeing the same issue when using Vue Draggable - elements being sorted and dragged are wrapped with a vue-router component and (on firefox), as the item is dropped into the draggable element, the click event triggers, and fires the vue-router to a different page.

Not happening in Chrome.

@DanielBickler
Copy link

Same here with Vue Draggable 4.1.0 firing an unexpected click event on Firefox when dragging within the same column.
We added an @click handler to the element being dragged and on non-FF browsers or when dragged between columns the click is not triggered, however, it is triggered when the element is dropped anywhere within its column.

We are using forceFeedback = true because that was the only way we could get AutoScroll to work with a good user experience. Maybe that's contributing to the problem?

The click event is fired after onEnd so there's no way to easily stop it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants