Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(modal): fix modal closed resolution
Browse files Browse the repository at this point in the history
- Correctly resolve modal closed promise on close or dismissal

Closes #5322
Closes #5326
  • Loading branch information
andrej.anafinow authored and wesleycho committed Jan 21, 2016
1 parent 5fcca2e commit d5a48ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,30 @@ describe('$uibModal', function() {

it('should resolve the closed promise when modal is closed', function() {
var modal = open({template: '<div>Content</div>'});
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: '<div>Content</div>'});
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() {
Expand Down

0 comments on commit d5a48ea

Please sign in to comment.