From 1a54aad707f1e008df994a161e12ddb4ed114bbd Mon Sep 17 00:00:00 2001 From: "maksym.koretskyi" Date: Thu, 14 Apr 2016 20:07:48 +0300 Subject: [PATCH] Fixed #5806: Modal dialog closes when mouse button is pressed over the dialog window but released outside the window --- src/modal/modal.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index f0b82a4fd2..0a10df8da5 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -157,8 +157,18 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p } }; - // moved from template to fix issue #2280 - element.on('click', scope.close); + var pointerDownElement; + element.on('mousedown', function (event) { + pointerDownElement = event.target; + }); + + element.on('mouseup', function (event) { + var element = event.target; + + if (element === pointerDownElement) { + scope.close(event); + } + }); // 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