Ticket #8268 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

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

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

Change History

comment:1 Changed 3 years ago by Courtland

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

Hopefully I'm doing this correctly...

comment:2 Changed 3 years ago by Courthead

  • Status changed from new to closed
  • Resolution set to fixed

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

comment:3 Changed 3 years ago by Scott González

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

comment:4 Changed 3 years ago by scott.gonzalez

  • Milestone changed from 1.9 to 1.8.21
Note: See TracTickets for help on using tickets.