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

Commit d1e7e64

Browse files
committed
Fixes bug with backdrop close event
Fixes bug with text selection and mouse up event on modal backdrop.
1 parent aec5304 commit d1e7e64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/modal/modal.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
145145
element.addClass(attrs.windowClass || '');
146146
element.addClass(attrs.windowTopClass || '');
147147
scope.size = attrs.size;
148+
scope.mouseDownEvt = scope.mouseUpEvt = null;
148149

149150
scope.close = function(evt) {
150151
var modal = $modalStack.getTop();
151152
if (modal && modal.value.backdrop &&
152153
modal.value.backdrop !== 'static' &&
153-
evt.target === evt.currentTarget) {
154+
scope.mouseDownEvt && scope.mouseUpEvt &&
155+
scope.mouseDownEvt.target === scope.mouseUpEvt.target) {
154156
evt.preventDefault();
155157
evt.stopPropagation();
156158
$modalStack.dismiss(modal.key, 'backdrop click');
@@ -159,6 +161,12 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
159161

160162
// moved from template to fix issue #2280
161163
element.on('click', scope.close);
164+
element.on('mousedown', function(evt) {
165+
scope.mouseDownEvt = evt;
166+
});
167+
element.on('mouseup', function(evt) {
168+
scope.mouseUpEvt = evt;
169+
});
162170

163171
// This property is only added to the scope for the purpose of detecting when this directive is rendered.
164172
// We can detect that by using this property in the template associated with this directive and then use

0 commit comments

Comments
 (0)