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

Fixes bug with backdrop click #5911

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
};

// moved from template to fix issue #2280
element.on('click', scope.close);

element.on('mousedown', function(evt1) {
element.one('mouseup', function(evt2) {
if (evt1.target === evt2.target) {
scope.close.apply(this, arguments);
}
});
});

// This property is only added to the scope for the purpose of detecting when this directive is rendered.
// We can detect that by using this property in the template associated with this directive and then use
Expand Down
5 changes: 4 additions & 1 deletion src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,10 @@ describe('$uibModal', function() {
var modal = open({template: '<div>Content</div>'});
expect($document).toHaveModalsOpen(1);

$document.find('body > div.modal').click();
var selector = 'body > div.modal';
$document.find(selector).mousedown();
$document.find(selector).mouseup();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be the backdrop?

$document.find(selector).click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate test - you could just copy/paste the test this is modifying, and revert the original test.

$animate.flush();
$rootScope.$digest();
$animate.flush();
Expand Down