This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +42
-6
lines changed
Expand file tree Collapse file tree 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'])
201201
202202
203203 $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+
204210 /**
205211 * If something within the freshly-opened modal already has focus (perhaps via a
206212 * directive that causes focus). then no need to try and focus anything.
@@ -222,12 +228,6 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
222228 }
223229 }
224230 } ) ;
225-
226- // Notify {@link $modalStack } that modal is rendered.
227- var modal = $modalStack . getTop ( ) ;
228- if ( modal ) {
229- $modalStack . modalRendered ( modal . key ) ;
230- }
231231 } ) ;
232232 }
233233 } ;
Original file line number Diff line number Diff line change @@ -305,6 +305,42 @@ describe('$uibModal', function() {
305305 close ( modalInstance , 'closing in test' , true ) ;
306306 } ) ;
307307
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+
308344 it ( 'should not throw an exception on a second dismiss' , function ( ) {
309345 var modal = open ( { template : '<div>Content</div>' } ) ;
310346
You can’t perform that action at this time.
0 commit comments