Skip to main content

Search and Top Navigation

#8268 closed bug (fixed)

Opened April 22, 2012 01:16AM UTC

Closed May 22, 2012 12:01PM UTC

Last modified May 22, 2012 12:12PM UTC

Items may not be inserted into the correct position when dragged between connected sortables

Reported by: Courtland Owned by:
Priority: minor Milestone: 1.8.21
Component: ui.sortable Version: 1.8.19
Keywords: Cc:
Blocked by: Blocking:
Description

Let's say you have two sortables connected using "connectWith" property. You drag an item from sortable A to the top of sortable B, expecting it to be inserted into the top position. Instead, it's inserted into the second position, or sometimes even the last position. If -- without letting go of the element -- you move it back out of the list and then back to the top, it begins working as expected. (You can try it out with the sortable demo of connected lists: http://jqueryui.com/demos/sortable/#connect-lists)

I've reproduced this behavior. it on the latest versions of Chrome, Firefox, and Safari. After looking at the code, I believe the issue is there, not with the browser. It seems that there are two issues:

1. In the refreshPositions function, positions aren't being calculated for inactive containers. So when you to drag an item into a different container, no positions have been saved for this container's items. This makes it impossible to determine where to insert the new item into the container's list of items.

2. When dragging an item into a new container, the "direction" variable is not being set, so we don't know if we're dragging it from above or from below. This is necessary for determining, for example, whether to insert the item above or below the first element in the list.

Anwyay, this is my first time reporting/attempting to fix a bug, but hopefully I did it correctly. I'll

Attachments (0)
Change History (4)

Changed April 22, 2012 01:38AM UTC by Courtland comment:1

Just submitted a pull request for commit a6fda228b053d5190299e6537f219b0b3eac44ff: https://github.com/jquery/jquery-ui/pull/637

Hopefully I'm doing this correctly...

Changed May 22, 2012 12:01PM UTC by Courthead comment:2

resolution: → fixed
status: newclosed

Sortable: calculating item positions on the fly and setting the direction variable when inserting an item into a different sortable. Fixed #8268 - Items may not be inserted into the correct position when dragged between connected sortables

Changeset: c42bdcecf825e295f483413f8d20b2079947faec

Changed May 22, 2012 12:04PM UTC by Scott González comment:3

Sortable: calculating item positions on the fly and setting the direction variable when inserting an item into a different sortable. Fixed #8268 - Items may not be inserted into the correct position when dragged between connected sortables

(cherry picked from commit c42bdcecf825e295f483413f8d20b2079947faec)

Conflicts:

ui/jquery.ui.sortable.js

Changeset: b76ac3057fbb9040481b4217743a4a4f5df2a5c2

Changed May 22, 2012 12:12PM UTC by scottgonzalez comment:4

milestone: 1.91.8.21