]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Ensure correct widget removes helper in connectToSortable
authorMike Sherov <mike.sherov@gmail.com>
Sun, 24 Aug 2014 19:06:51 +0000 (15:06 -0400)
committerMike Sherov <mike.sherov@gmail.com>
Mon, 25 Aug 2014 01:30:49 +0000 (21:30 -0400)
ui/draggable.js

index 997bba107b1b00a0202a6bf5557dc875b2190032..d290ea539b82466c70960e6bb29ffc2b0662cfb4 100644 (file)
@@ -729,13 +729,16 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                        item: inst.element
                });
 
+               inst.cancelHelperRemoval = false;
+
                $.each(inst.sortables, function() {
                        if (this.instance.isOver) {
 
                                this.instance.isOver = 0;
 
-                               inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
-                               this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
+                               // Allow this sortable to handle removing the helper
+                               inst.cancelHelperRemoval = true;
+                               this.instance.cancelHelperRemoval = false;
 
                                //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
                                if (this.shouldRevert) {
@@ -755,7 +758,11 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        left: ""
                                });
                        } else {
-                               this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
+                               // Prevent this Sortable from removing the helper.
+                               // However, don't set the draggable to remove the helper
+                               // either as another connected Sortable may yet handle the removal.
+                               this.instance.cancelHelperRemoval = true;
+
                                this.instance._trigger("deactivate", event, uiSortable);
                        }