Skip to main content

Search and Top Navigation

#5772 open bug ()

Opened June 26, 2010 06:32PM UTC

Last modified January 21, 2015 03:52PM UTC

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: bryanam@gmail.com
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 (12)

Changed June 29, 2010 05:32AM UTC by meyerovb comment:1

Sorry, forgot to set component to ui.sortable

Changed July 30, 2010 10:50AM UTC by jzaefferer comment:2

component: ui.coreui.sortable

Changed June 26, 2011 09:21PM UTC by medmunds comment:3

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

Changed September 23, 2011 07:27PM UTC by jinxdone comment:4

_comment0: 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.1316806631043250

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/

Changed October 11, 2012 09:07PM UTC by scottgonzalez comment:5

milestone: TBD2.0.0

Changed November 08, 2012 02:03AM UTC by mikesherov comment:6

keywords: sortable containmenthaspatch
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!

Changed November 09, 2012 01:40PM UTC by mikesherov comment:7

#8794 is a duplicate of this ticket.

Changed March 12, 2013 09:02PM UTC by dcarrith comment:8

_comment0: 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. \ \ 1363122633687496
_comment1: 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 seems to work as expected. \ \ 1363122671545180

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.

Changed March 16, 2013 06:57PM UTC by tj.vantoll comment:9

Possibly a duplicate of #4428 because both have to due with not being able to reorder when using the

containment
option.

Changed August 16, 2013 07:53AM UTC by morchard comment:10

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

Changed January 24, 2014 08:20AM UTC by morchard comment:11

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

Changed January 21, 2015 03:52PM UTC by morchard comment:12

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