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

Request: Don't start dragging unless cursor been dragged x pixels. #35

Closed
tornstrom opened this issue Jul 22, 2016 · 5 comments
Closed

Comments

@tornstrom
Copy link

I ran into an issue where I have items that expand when clicked. When making them sortable they no longer respond to a click, instead they become dragged immediately. I can get around this by setting the "pressDelay" but then you have to wait for the delay before it's draggable which I noticed that people tend not to do.
I'd like a way to not start the sorting unless you have actually dragged the cursor for say 5px.

@NeXTs
Copy link

NeXTs commented Jul 25, 2016

Yes, I guess it will be much more evident to users than "pressDelay" option
Really looking forward to this feature too

@bvaughn
Copy link
Contributor

bvaughn commented Jul 27, 2016

I encountered a similar issue with sortable FlexTable rows. My table contained <input> tags which stopped working when I made the whole row draggable. (Clicks on the <input> would just start a drag.) I ended up using the drag-handle approach, which works pretty well. But if there was some sort of threshold it might be nicer still.

This might still lead to edge-cases when it comes to things like text-selection so maybe some way to cancel/block a drag (eg #36) might also be nice.

clauderic pushed a commit that referenced this issue Sep 5, 2016
… Prevent right click from causing sort start (#46)
@clauderic
Copy link
Owner

Just published 0.0.8 with this feature. Just pass in a distance prop to your SortableContainer.

Alternatively, you may also use shouldCancelStart, which was just released today as well. This function gets invoked before sorting begins and can be used to programatically cancel sorting before it begins.

Here's the default implementation:

function shouldCancelStart(e) {
    // Cancel sorting if the event target is an `input`, `textarea`, `select` or `option`
    if (['input', 'textarea', 'select', 'option'].indexOf(e.target.tagName.toLowerCase()) !== -1) {
        return true; // Return true to cancel sorting
    }
}

@NeXTs
Copy link

NeXTs commented Sep 5, 2016

aww yeah!

@tornstrom
Copy link
Author

Sweet, thanks @clauderic!

DimitarNestorov pushed a commit to codemotionapps/react-sortable-hoc that referenced this issue Feb 4, 2019
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

4 participants