Ticket #8268 (closed bug: fixed)
Items may not be inserted into the correct position when dragged between connected sortables
|Reported by:||Courtland||Owned by:|
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:
- 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.
- 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