Opened 13 years ago
Last modified 8 years ago
#5772 open bug
Sortable: containment parent restricting replacement of first and last elements
Reported by: | meyerovb | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 2.0.0 |
Component: | ui.sortable | Version: | 1.8.2 |
Keywords: | haspatch | Cc: | [email protected]… |
Blocked by: | Blocking: |
Description
If you contain a sortable to parent, then when you hold the top part of any element, you cannot move it into the last position (vice versa for first position). See attachment for simple code example.
Attachments (1)
Change History (13)
Changed 13 years ago by
Attachment: | jQuerySortable.html added |
---|
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Component: | ui.core → ui.sortable |
---|
comment:3 Changed 12 years ago by
Still seeing this in 1.8.13.
Setting option tolerance: 'pointer' seems to work around the issue (though maybe it causes some other problem I'm missing).
comment:4 Changed 11 years ago by
I added an additional check in the sortable for whether it's hitting the sides of the containment. The effect should be that it will reorder first/last elements when the draggable hits the side of the containment.
I also added a special case ""if (!horizontalDirection && !verticalDirection) return false;"" because that was leading to inconsistent behavior. (What are you supposed to be comparing if there is no information which axis is being dragged on?)
https://github.com/jinxdone/jquery-ui/commit/f9d87d57f271b49606be48237d60e42d22914369
Needs review and testing.
comment:5 Changed 10 years ago by
Milestone: | TBD → 2.0.0 |
---|
comment:6 Changed 10 years ago by
Keywords: | haspatch added; sortable containment removed |
---|---|
Status: | new → open |
Summary: | Sortable containment parent restricting replacement of first and last elements → Sortable: containment parent restricting replacement of first and last elements |
Confirmed on latest: http://jsfiddle.net/2q2YE/ with a working patch!
comment:8 Changed 10 years ago by
I think issue #5620 illustrates the fundamental problem. See my comment for more info: http://bugs.jqueryui.com/ticket/5620#comment:6
To summarize though, I think it comes down to where the mouse pointer is when you grab the item to drag. If it is below the middle point of the item you're grabbing, and the tolerance method is "intersect" (i.e. the default) then you will never be able to drop the item above the first item in the list (to make it the new first item). If the mouse cursor is above the middle point of the item you're grabbing, then you will not be able to drop it as the last item in the list. That's because the "pointer" point (which is what the "intersect" condition seems to be based) will never cross the half way point in either of those scenarios.
I think the default "tolerance" method "intersect" should be updated to figure out the dimensions of the item being dragged, and then base the determination of the intersection on the edges of the dragged item rather than the mouse pointer. The "pointer" method of "tolerance" seems to work as expected.
comment:9 Changed 10 years ago by
Possibly a duplicate of #4428 because both have to due with not being able to reorder when using the containment
option.
comment:10 Changed 10 years ago by
I've made a pull request to improve the behaviour in this scenario, if someone could take a look at it.
comment:11 Changed 9 years ago by
I've since updated the pull request above, after getting some feedback. Could someone take another look?
comment:12 Changed 8 years ago by
FYI my colleague has picked up and update the pull request above, which can now be found here: https://github.com/jquery/jquery-ui/pull/1424
Sorry, forgot to set component to ui.sortable