Ticket #5772 (open bug)

Opened 4 years ago

Last modified 8 months ago

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@…
Blocking: Blocked by:

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

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

Change History

Changed 4 years ago by meyerovb

comment:1 Changed 4 years ago by meyerovb

Sorry, forgot to set component to ui.sortable

comment:2 Changed 4 years ago by joern.zaefferer

  • Component changed from ui.core to ui.sortable

comment:3 Changed 3 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 3 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 3 years ago by jinxdone (previous) (diff)

comment:5 Changed 2 years ago by scott.gonzalez

  • Milestone changed from TBD to 2.0.0

comment:6 Changed 23 months ago by mikesherov

  • Keywords haspatch added; sortable containment removed
  • Status changed from new to open
  • Summary changed from Sortable containment parent restricting replacement of first and last elements to Sortable: containment parent restricting replacement of first and last elements

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

comment:7 Changed 23 months ago by mikesherov

#8794 is a duplicate of this ticket.

comment:8 Changed 19 months 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.

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.

Last edited 19 months ago by dcarrith (previous) (diff)

comment:9 Changed 18 months 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 13 months 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 8 months ago by morchard

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

Note: See TracTickets for help on using tickets.