@@ -400,6 +400,42 @@ describe('uiSortable', function() {
400
400
} ) ;
401
401
} ) ;
402
402
403
+ it ( 'should update model when sorting a "falsy" item between sortables' , function ( ) {
404
+ inject ( function ( $compile , $rootScope ) {
405
+ var elementTop , elementBottom ;
406
+ elementTop = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul>' ) ( $rootScope ) ;
407
+ elementBottom = $compile ( '<ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul>' ) ( $rootScope ) ;
408
+ $rootScope . $apply ( function ( ) {
409
+ $rootScope . itemsTop = [ 0 , 'Top Two' , 'Top Three' ] ;
410
+ $rootScope . itemsBottom = [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ;
411
+ $rootScope . opts = { connectWith : '.cross-sortable' } ;
412
+ } ) ;
413
+
414
+ host . append ( elementTop ) . append ( elementBottom ) ;
415
+
416
+ var li1 = elementTop . find ( ':eq(0)' ) ;
417
+ var li2 = elementBottom . find ( ':eq(0)' ) ;
418
+ var dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
419
+ li1 . simulate ( 'drag' , { dy : dy } ) ;
420
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 'Top Three' ] ) ;
421
+ expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 0 , 'Bottom Two' , 'Bottom Three' ] ) ;
422
+ expect ( $rootScope . itemsTop ) . toEqualListContent ( elementTop ) ;
423
+ expect ( $rootScope . itemsBottom ) . toEqualListContent ( elementBottom ) ;
424
+
425
+ li1 = elementBottom . find ( ':eq(1)' ) ;
426
+ li2 = elementTop . find ( ':eq(1)' ) ;
427
+ dy = - EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) - ( li1 . position ( ) . top - li2 . position ( ) . top ) ;
428
+ li1 . simulate ( 'drag' , { dy : dy } ) ;
429
+ expect ( $rootScope . itemsTop ) . toEqual ( [ 'Top Two' , 0 , 'Top Three' ] ) ;
430
+ expect ( $rootScope . itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
431
+ expect ( $rootScope . itemsTop ) . toEqualListContent ( elementTop ) ;
432
+ expect ( $rootScope . itemsBottom ) . toEqualListContent ( elementBottom ) ;
433
+
434
+ $ ( elementTop ) . remove ( ) ;
435
+ $ ( elementBottom ) . remove ( ) ;
436
+ } ) ;
437
+ } ) ;
438
+
403
439
it ( 'should work when "placeholder" option is used' , function ( ) {
404
440
inject ( function ( $compile , $rootScope ) {
405
441
var elementTop , elementBottom ;
0 commit comments