From d5a48eaff02e0a36a1e0e2a9e25e91c6937e221c Mon Sep 17 00:00:00 2001 From: "andrej.anafinow" Date: Thu, 21 Jan 2016 16:17:04 +0100 Subject: [PATCH] fix(modal): fix modal closed resolution - Correctly resolve modal closed promise on close or dismissal Closes #5322 Closes #5326 --- src/modal/modal.js | 2 +- src/modal/test/modal.spec.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) 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() {