This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree 2 files changed +27
-2
lines changed 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,8 @@ angular.module('ui.sortable', [])
133
133
// the start and stop of repeat sections and sortable doesn't
134
134
// respect their order (even if we cancel, the order of the
135
135
// comments are still messed up).
136
- if ( hasSortingHelper ( element , ui ) && ! ui . item . sortable . received ) {
136
+ if ( hasSortingHelper ( element , ui ) && ! ui . item . sortable . received &&
137
+ element . sortable ( 'option' , 'appendTo' ) === 'parent' ) {
137
138
// restore all the savedNodes except .ui-sortable-helper element
138
139
// (which is placed last). That way it will be garbage collected.
139
140
savedNodes = savedNodes . not ( savedNodes . last ( ) ) ;
Original file line number Diff line number Diff line change @@ -381,6 +381,30 @@ describe('uiSortable', function() {
381
381
} ) ;
382
382
} ) ;
383
383
384
+ it ( 'should work when "helper: clone" and "appendTo" options are used together' , function ( ) {
385
+ inject ( function ( $compile , $rootScope ) {
386
+ var element ;
387
+ 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 ) ;
388
+ $rootScope . $apply ( function ( ) {
389
+ $rootScope . opts = {
390
+ helper : 'clone' ,
391
+ appendTo : 'body'
392
+ } ;
393
+ $rootScope . items = [ 'One' , 'Two' , 'Three' ] ;
394
+ } ) ;
395
+
396
+ host . append ( element ) ;
397
+
398
+ var li = element . find ( ':eq(1)' ) ;
399
+ var dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
400
+ li . simulate ( 'drag' , { dy : dy } ) ;
401
+ expect ( $rootScope . items ) . toEqual ( [ 'One' , 'Three' , 'Two' ] ) ;
402
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
403
+
404
+ $ ( element ) . remove ( ) ;
405
+ } ) ;
406
+ } ) ;
407
+
384
408
it ( 'should work when "helper: clone" and "placeholder" options are used together.' , function ( ) {
385
409
inject ( function ( $compile , $rootScope ) {
386
410
var element ;
@@ -648,4 +672,4 @@ describe('uiSortable', function() {
648
672
649
673
} ) ;
650
674
651
- } ) ;
675
+ } ) ;
You can’t perform that action at this time.
0 commit comments