@@ -189,6 +189,47 @@ describe('uiSortable', function() {
189
189
} ) ;
190
190
} ) ;
191
191
192
+ it ( 'should continue to work after a drag is reverted' , function ( ) {
193
+ inject ( function ( $compile , $rootScope ) {
194
+ var element ;
195
+ element = $compile ( '<ul ui-sortable ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
196
+ $rootScope . $apply ( function ( ) {
197
+ $rootScope . opts = {
198
+ placeholder : "sortable-item"
199
+ } ;
200
+ $rootScope . items = [ "One" , "Two" , "Three" ] ;
201
+ } ) ;
202
+
203
+ host . append ( element ) ;
204
+
205
+ var li = element . find ( ':eq(0)' ) ;
206
+ var dy = ( 2 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
207
+ li . simulate ( 'dragAndRevert' , { dy : dy } ) ;
208
+ expect ( $rootScope . items ) . toEqual ( [ "One" , "Two" , "Three" ] ) ;
209
+ expect ( $rootScope . items ) . toEqualListContent ( element ) ;
210
+
211
+ li = element . find ( ':eq(0)' ) ;
212
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
213
+ li . simulate ( 'drag' , { dy : dy } ) ;
214
+ expect ( $rootScope . items ) . toEqual ( [ "Two" , "One" , "Three" ] ) ;
215
+ expect ( $rootScope . items ) . toEqualListContent ( element ) ;
216
+
217
+ li = element . find ( ':eq(1)' ) ;
218
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
219
+ li . simulate ( 'drag' , { dy : dy } ) ;
220
+ expect ( $rootScope . items ) . toEqual ( [ "Two" , "Three" , "One" ] ) ;
221
+ expect ( $rootScope . items ) . toEqualListContent ( element ) ;
222
+
223
+ li = element . find ( ':eq(1)' ) ;
224
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
225
+ li . simulate ( 'drag' , { dy : dy } ) ;
226
+ expect ( $rootScope . items ) . toEqual ( [ "Two" , "One" , "Three" ] ) ;
227
+ expect ( $rootScope . items ) . toEqualListContent ( element ) ;
228
+
229
+ $ ( element ) . remove ( ) ;
230
+ } ) ;
231
+ } ) ;
232
+
192
233
} ) ;
193
234
194
235
describe ( 'Multiple sortables related' , function ( ) {
0 commit comments