This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +42
-2
lines changed
2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -324,8 +324,11 @@ angular.module('ui.bootstrap.modal', [])
324
324
$modalStack . close = function ( modalInstance , result ) {
325
325
var modalWindow = openedWindows . get ( modalInstance ) ;
326
326
if ( modalWindow && broadcastClosing ( modalWindow , result , true ) ) {
327
- modalWindow . value . deferred . resolve ( result ) ;
327
+ // Defer resolution until after modal window is closed - #3787
328
328
removeModalWindow ( modalInstance , modalWindow . value . modalOpener ) ;
329
+ $timeout ( function ( ) {
330
+ modalWindow . value . deferred . resolve ( result ) ;
331
+ } ) ;
329
332
return true ;
330
333
}
331
334
return ! modalWindow ;
@@ -334,8 +337,11 @@ angular.module('ui.bootstrap.modal', [])
334
337
$modalStack . dismiss = function ( modalInstance , reason ) {
335
338
var modalWindow = openedWindows . get ( modalInstance ) ;
336
339
if ( modalWindow && broadcastClosing ( modalWindow , reason , false ) ) {
337
- modalWindow . value . deferred . reject ( reason ) ;
340
+ // Defer rejection until after modal window is dismissed - #3787
338
341
removeModalWindow ( modalInstance , modalWindow . value . modalOpener ) ;
342
+ $timeout ( function ( ) {
343
+ modalWindow . value . deferred . reject ( reason ) ;
344
+ } ) ;
339
345
return true ;
340
346
}
341
347
return ! modalWindow ;
Original file line number Diff line number Diff line change @@ -673,6 +673,40 @@ describe('$modal', function () {
673
673
expect ( $document . find ( '.modal-backdrop' ) ) . not . toHaveClass ( 'fade' ) ;
674
674
} ) ;
675
675
676
+ it ( 'should resolve the promise after the animation starts' , function ( ) {
677
+ var modal = open ( {
678
+ template : '<div>Small modal dialog</div>' ,
679
+ animation : false
680
+ } ) ;
681
+
682
+ expect ( $document ) . toHaveModalsOpen ( 1 ) ;
683
+
684
+ modal . result . then ( function ( ) {
685
+ expect ( $document ) . toHaveModalsOpen ( 0 ) ;
686
+ } , function ( ) {
687
+ expect ( true ) . toBe ( false ) ;
688
+ } ) ;
689
+
690
+ close ( modal ) ;
691
+ } ) ;
692
+
693
+
694
+ it ( 'should reject the promise after the animation starts' , function ( ) {
695
+ var modal = open ( {
696
+ template : '<div>Small modal dialog</div>' ,
697
+ animation : false
698
+ } ) ;
699
+
700
+ expect ( $document ) . toHaveModalsOpen ( 1 ) ;
701
+
702
+ modal . result . then ( function ( ) {
703
+ expect ( true ) . toBe ( false ) ;
704
+ } , function ( ) {
705
+ expect ( $document ) . toHaveModalsOpen ( 0 ) ;
706
+ } ) ;
707
+
708
+ dismiss ( modal ) ;
709
+ } ) ;
676
710
} ) ;
677
711
678
712
} ) ;
You can’t perform that action at this time.
0 commit comments