diff --git a/src/modal/modal.js b/src/modal/modal.js index 78bd5e926e..c88840562a 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -302,7 +302,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) openedClasses.remove(modalBodyClass, modalInstance); appendToElement.toggleClass(modalBodyClass, openedClasses.hasKey(modalBodyClass)); toggleTopWindowClass(true); - }); + }, modalWindow.closedDeferred); checkRemoveBackdrop(); //move focus to specified element if available, or else to body diff --git a/src/modal/test/modal.spec.js b/src/modal/test/modal.spec.js index 0db7716c99..3695927dff 100644 --- a/src/modal/test/modal.spec.js +++ b/src/modal/test/modal.spec.js @@ -480,16 +480,30 @@ describe('$uibModal', function() { it('should resolve the closed promise when modal is closed', function() { var modal = open({template: '
Content
'}); + var closed = false; close(modal, 'closed ok'); - expect(modal.closed).toBeResolvedWith(undefined); + modal.closed.then(function() { + closed = true; + }); + + $rootScope.$digest(); + + expect(closed).toBe(true); }); it('should resolve the closed promise when modal is dismissed', function() { var modal = open({template: '
Content
'}); + var closed = false; dismiss(modal, 'esc'); - expect(modal.closed).toBeResolvedWith(undefined); + modal.closed.then(function() { + closed = true; + }); + + $rootScope.$digest(); + + expect(closed).toBe(true); }); it('should expose a promise linked to the templateUrl / resolve promises', function() {