Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

fix(sortable): fix incorrect helper returned from getSortingHelper(). #514

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ angular.module('ui.sortable', [])
},
link: function(scope, element, attrs, ngModel) {
var savedNodes;
var helper;

function combineCallbacks(first, second){
var firstIsFunc = typeof first === 'function';
Expand Down Expand Up @@ -190,8 +191,7 @@ angular.module('ui.sortable', [])
if (hasSortingHelper(element, ui) &&
element.sortable( 'option', 'appendTo' ) === 'parent') {
// The .ui-sortable-helper element (that's the default class name)
// is placed last.
result = savedNodes.last();
result = helper;
}
return result;
}
Expand Down Expand Up @@ -331,6 +331,7 @@ angular.module('ui.sortable', [])
// This is inside activate (instead of start) in order to save
// both lists when dragging between connected lists.
savedNodes = savedNodesOrigin.contents();
helper = ui.helper;

// If this list has a placeholder (the connected lists won't),
// don't inlcude it in saved nodes.
Expand Down Expand Up @@ -428,9 +429,10 @@ angular.module('ui.sortable', [])
savedNodes.appendTo(elementContext.savedNodesOrigin);
}

// It's now safe to clear the savedNodes
// It's now safe to clear the savedNodes and helper
// since stop is the last callback.
savedNodes = null;
helper = null;
};

callbacks.receive = function(e, ui) {
Expand Down