Skip to content

Commit 2b899cc

Browse files
Martin Hochscottgonzalez
Martin Hoch
authored andcommitted
Sortable: Fixed jerkiness with nested-sortables. Fixes #4857 - Nested lists don't work properly with sortable.
1 parent 6514607 commit 2b899cc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ui/jquery.ui.sortable.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,16 @@ $.widget("ui.sortable", $.ui.mouse, {
296296
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
297297
if (!intersection) continue;
298298

299-
if(itemElement != this.currentItem[0] //cannot intersect with itself
299+
// Only put the placeholder inside the current Container, skip all
300+
// items form other containers. This works because when moving
301+
// an item from one container to another the
302+
// currentContainer is switched before the placeholder is moved.
303+
//
304+
// Without this moving items in "sub-sortables" can cause the placeholder to jitter
305+
// beetween the outer and inner container.
306+
if (item.instance !== this.currentContainer) continue;
307+
308+
if (itemElement != this.currentItem[0] //cannot intersect with itself
300309
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
301310
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
302311
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)

0 commit comments

Comments
 (0)