From 9606f5218e6687dd3c106941827570619e454143 Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Mon, 16 May 2022 20:37:33 -0300 Subject: [PATCH] Fix try close modal when select text and mouseup outside note.. Issue #27 --- js/script.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index 8757da9..e983912 100644 --- a/js/script.js +++ b/js/script.js @@ -433,8 +433,20 @@ View.prototype = { /* * Modal actions. */ - // Cancel when click outside the modal. + + /** + * Save references of event target on mouse down to avoid manage click on + * next event handler when selecting outside text outside the content. + */ + var _clickTarget = undefined; + $('#div-content').on('mousedown', function (event) { + _clickTarget = event.target; + }); + + // Cancel when explicit click outside the modal. $('#div-content').on('click', '.modal-note-background', function (event) { + if (_clickTarget != event.target) + return; event.stopPropagation(); if (self._colorPick.isVisible()) { self._colorPick.close();