This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +42
-6
lines changed
2 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,12 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
201
201
202
202
203
203
$q . when ( animationPromise ) . then ( function ( ) {
204
+ // Notify {@link $modalStack } that modal is rendered.
205
+ var modal = $modalStack . getTop ( ) ;
206
+ if ( modal ) {
207
+ $modalStack . modalRendered ( modal . key ) ;
208
+ }
209
+
204
210
/**
205
211
* If something within the freshly-opened modal already has focus (perhaps via a
206
212
* directive that causes focus). then no need to try and focus anything.
@@ -222,12 +228,6 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
222
228
}
223
229
}
224
230
} ) ;
225
-
226
- // Notify {@link $modalStack } that modal is rendered.
227
- var modal = $modalStack . getTop ( ) ;
228
- if ( modal ) {
229
- $modalStack . modalRendered ( modal . key ) ;
230
- }
231
231
} ) ;
232
232
}
233
233
} ;
Original file line number Diff line number Diff line change @@ -305,6 +305,42 @@ describe('$uibModal', function() {
305
305
close ( modalInstance , 'closing in test' , true ) ;
306
306
} ) ;
307
307
308
+ it ( 'should resolve rendered promise when animation is complete' , function ( ) {
309
+ var modalInstance = {
310
+ result : $q . defer ( ) ,
311
+ opened : $q . defer ( ) ,
312
+ closed : $q . defer ( ) ,
313
+ rendered : $q . defer ( ) ,
314
+ close : function ( result ) {
315
+ return $uibModalStack . close ( modalInstance , result ) ;
316
+ } ,
317
+ dismiss : function ( reason ) {
318
+ return $uibModalStack . dismiss ( modalInstance , reason ) ;
319
+ }
320
+ } ;
321
+ var rendered = false ;
322
+ modalInstance . rendered . promise . then ( function ( ) {
323
+ rendered = true ;
324
+ } ) ;
325
+
326
+ $uibModalStack . open ( modalInstance , {
327
+ appendTo : angular . element ( document . body ) ,
328
+ scope : $rootScope . $new ( ) ,
329
+ deferred : modalInstance . result ,
330
+ renderDeferred : modalInstance . rendered ,
331
+ closedDeferred : modalInstance . closed ,
332
+ content : '<div id="test">test</div>'
333
+ } ) ;
334
+
335
+ $rootScope . $digest ( ) ;
336
+
337
+ expect ( rendered ) . toBe ( false ) ;
338
+
339
+ $animate . flush ( ) ;
340
+
341
+ expect ( rendered ) . toBe ( true ) ;
342
+ } ) ;
343
+
308
344
it ( 'should not throw an exception on a second dismiss' , function ( ) {
309
345
var modal = open ( { template : '<div>Content</div>' } ) ;
310
346
You can’t perform that action at this time.
0 commit comments