This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 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', [])
133133 // the start and stop of repeat sections and sortable doesn't
134134 // respect their order (even if we cancel, the order of the
135135 // 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' ) {
137138 // restore all the savedNodes except .ui-sortable-helper element
138139 // (which is placed last). That way it will be garbage collected.
139140 savedNodes = savedNodes . not ( savedNodes . last ( ) ) ;
Original file line number Diff line number Diff line change @@ -381,6 +381,30 @@ describe('uiSortable', function() {
381381 } ) ;
382382 } ) ;
383383
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+
384408 it ( 'should work when "helper: clone" and "placeholder" options are used together.' , function ( ) {
385409 inject ( function ( $compile , $rootScope ) {
386410 var element ;
@@ -648,4 +672,4 @@ describe('uiSortable', function() {
648672
649673 } ) ;
650674
651- } ) ;
675+ } ) ;
You can’t perform that action at this time.
0 commit comments