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)

jQuerySortable.html (1.2 KB) - added by meyerovb 13 years ago.

Download all attachments as: .zip

Change History (13)

Changed 13 years ago by meyerovb

Attachment: jQuerySortable.html added

comment:1 Changed 13 years ago by meyerovb

Sorry, forgot to set component to ui.sortable

comment:2 Changed 13 years ago by Jörn Zaefferer

Component: ui.coreui.sortable

comment:3 Changed 12 years ago by medmunds

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 12 years ago by jinxdone

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.

I prepared an example by overriding the method; Default: http://jsfiddle.net/kY5n5/ With fix applied: http://jsfiddle.net/9sm2G/2/

Last edited 12 years ago by jinxdone (previous) (diff)

comment:5 Changed 10 years ago by Scott González

Milestone: TBD2.0.0

comment:6 Changed 10 years ago by mikesherov

Keywords: haspatch added; sortable containment removed
Status: newopen
Summary: Sortable containment parent restricting replacement of first and last elementsSortable: containment parent restricting replacement of first and last elements

Confirmed on latest: http://jsfiddle.net/2q2YE/ with a working patch!

comment:7 Changed 10 years ago by mikesherov

#8794 is a duplicate of this ticket.

comment:8 Changed 10 years ago by dcarrith

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.

Version 0, edited 10 years ago by dcarrith (next)

comment:9 Changed 10 years ago by tj.vantoll

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 morchard

I've made a pull request to improve the behaviour in this scenario, if someone could take a look at it.

https://github.com/jquery/jquery-ui/pull/1060

comment:11 Changed 9 years ago by morchard

I've since updated the pull request above, after getting some feedback. Could someone take another look?

comment:12 Changed 8 years ago by morchard

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

Note: See TracTickets for help on using tickets.