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

Commit a20ee2f

Browse files
committed
fix(sortable): properly remove the sorting helper when a drag is reverted
1 parent 58c6c7b commit a20ee2f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sortable.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,13 @@ angular.module('ui.sortable', [])
262262
// if the item was not moved, then restore the elements
263263
// so that the ngRepeat's comment are correct.
264264
if ((!('dropindex' in ui.item.sortable) || ui.item.sortable.isCanceled()) &&
265-
!hasSortingHelper(element, ui)) {
265+
!angular.equals(element.contents(), savedNodes)) {
266+
267+
if (hasSortingHelper(element, ui) && element.sortable( 'option', 'appendTo' ) === 'parent') {
268+
// restore all the savedNodes except .ui-sortable-helper element
269+
// (which is placed last). That way it will be garbage collected.
270+
savedNodes = savedNodes.not(savedNodes.last());
271+
}
266272
savedNodes.appendTo(element);
267273
}
268274
}

0 commit comments

Comments
 (0)