Skip to content

Commit a611dd8

Browse files
committed
Draggable: Refresh sortables when draggable is added or removed
Since a sortable grows or shrinks when a draggable element is added to it, refresh the cached positions of sortables whenever an element is added or removed from the sortable. Refs #9675
1 parent 368fc83 commit a611dd8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ui/draggable.js

+12
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,12 @@ $.ui.plugin.add("draggable", "connectToSortable", {
834834
// used solely in the revert option to handle "valid/invalid".
835835
draggable.dropped = sortable.element;
836836

837+
// Need to refreshPositions of all sortables in the case that
838+
// adding to one sortable changes the location of the other sortables (#9675)
839+
$.each( draggable.sortables, function() {
840+
this.refreshPositions();
841+
});
842+
837843
// hack so receive/update callbacks work (mostly)
838844
draggable.currentItem = draggable.element;
839845
sortable.fromOutside = draggable;
@@ -882,6 +888,12 @@ $.ui.plugin.add("draggable", "connectToSortable", {
882888

883889
// Inform draggable that the helper is no longer in a valid drop zone
884890
draggable.dropped = false;
891+
892+
// Need to refreshPositions of all sortables just in case removing
893+
// from one sortable changes the location of other sortables (#9675)
894+
$.each( draggable.sortables, function() {
895+
this.refreshPositions();
896+
});
885897
}
886898
}
887899
});

0 commit comments

Comments
 (0)