Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules/
coverage/
junit/
dist/
out/
out/
2 changes: 1 addition & 1 deletion src/sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ angular.module('ui.sortable', [])
return inner;
};

scope.$watch('uiSortable', function(newVal /*, oldVal*/) {
scope.$watchCollection('uiSortable', function(newVal /*, oldVal*/) {
// ensure that the jquery-ui-sortable widget instance
// is still bound to the directive's element
var sortableWidgetInstance = getSortableWidgetInstance(element);
Expand Down
30 changes: 30 additions & 0 deletions test/sortable.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,36 @@ describe('uiSortable', function() {
});
});

it('should work when "helper: clone" and "appendTo" options are used together', function() {
inject(function($compile, $rootScope) {
var element;
element = $compile('<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}" class="sortable-item">{{ item }}</li></ul>')($rootScope);
$rootScope.$apply(function() {
$rootScope.opts = {
helper: 'clone',
appendTo: document.body
};
$rootScope.items = ['One', 'Two', 'Three'];
});

host.append(element);

var li = element.find(':eq(1)');
var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
li.simulate('drag', { dy: dy });
expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
expect($rootScope.items).toEqual(listContent(element));

li = element.find(':eq(2)');
dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
li.simulate('drag', { dy: dy });
expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
expect($rootScope.items).toEqual(listContent(element));

$(element).remove();
});
});

it('should work when "helper: clone" and "placeholder" options are used together.', function() {
inject(function($compile, $rootScope) {
var element;
Expand Down