Skip to content

Commit

Permalink
Sortable: cancelHelperRemoval only considers helper, not placeholder
Browse files Browse the repository at this point in the history
Refs #9675
  • Loading branch information
mikesherov committed Aug 26, 2014
1 parent aada9d5 commit 52a1de5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/unit/draggable/draggable_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ test( "connectToSortable, dragging clone into sortable", function() {
sortable = $( "#sortable" ).sortable(),
offsetSortable = sortable.offset();

$( sortable ).one( "sortbeforestop", function( event, ui ) {
$( sortable ).one( "sort", function( event, ui ) {
// http://bugs.jqueryui.com/ticket/8809
// Position issue when connected to sortable
deepEqual( ui.helper.offset(), offsetSortable, "sortable offset is correct" );
Expand Down
22 changes: 6 additions & 16 deletions ui/sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1253,18 +1253,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
}

this.dragging = false;
if(this.cancelHelperRemoval) {
if(!noPropagation) {
this._trigger("beforeStop", event, this._uiHash());
for (i=0; i < delayedTriggers.length; i++) {
delayedTriggers[i].call(this, event);
} //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
}

this.fromOutside = false;
return false;
}

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

if(this.helper[0] !== this.currentItem[0]) {
this.helper.remove();
if ( !this.cancelHelperRemoval ) {
if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
this.helper.remove();
}
this.helper = null;
}
this.helper = null;

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

this.fromOutside = false;
return true;
return !this.cancelHelperRemoval;

},

Expand Down

0 comments on commit 52a1de5

Please sign in to comment.