Skip to content

Commit 52a1de5

Browse files
committed
Sortable: cancelHelperRemoval only considers helper, not placeholder
Refs #9675
1 parent aada9d5 commit 52a1de5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

tests/unit/draggable/draggable_options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ test( "connectToSortable, dragging clone into sortable", function() {
305305
sortable = $( "#sortable" ).sortable(),
306306
offsetSortable = sortable.offset();
307307

308-
$( sortable ).one( "sortbeforestop", function( event, ui ) {
308+
$( sortable ).one( "sort", function( event, ui ) {
309309
// http://bugs.jqueryui.com/ticket/8809
310310
// Position issue when connected to sortable
311311
deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );

ui/sortable.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,18 +1253,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
12531253
}
12541254

12551255
this.dragging = false;
1256-
if(this.cancelHelperRemoval) {
1257-
if(!noPropagation) {
1258-
this._trigger("beforeStop", event, this._uiHash());
1259-
for (i=0; i < delayedTriggers.length; i++) {
1260-
delayedTriggers[i].call(this, event);
1261-
} //Trigger all delayed events
1262-
this._trigger("stop", event, this._uiHash());
1263-
}
1264-
1265-
this.fromOutside = false;
1266-
return false;
1267-
}
12681256

12691257
if(!noPropagation) {
12701258
this._trigger("beforeStop", event, this._uiHash());
@@ -1273,10 +1261,12 @@ return $.widget("ui.sortable", $.ui.mouse, {
12731261
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
12741262
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
12751263

1276-
if(this.helper[0] !== this.currentItem[0]) {
1277-
this.helper.remove();
1264+
if ( !this.cancelHelperRemoval ) {
1265+
if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
1266+
this.helper.remove();
1267+
}
1268+
this.helper = null;
12781269
}
1279-
this.helper = null;
12801270

12811271
if(!noPropagation) {
12821272
for (i=0; i < delayedTriggers.length; i++) {
@@ -1286,7 +1276,7 @@ return $.widget("ui.sortable", $.ui.mouse, {
12861276
}
12871277

12881278
this.fromOutside = false;
1289-
return true;
1279+
return !this.cancelHelperRemoval;
12901280

12911281
},
12921282

0 commit comments

Comments
 (0)