From 16a596f14942a48b7926a7ba9d69ee5416a52627 Mon Sep 17 00:00:00 2001 From: dimden Date: Sat, 16 Sep 2023 00:43:06 +0300 Subject: [PATCH] fix #536 --- scripts/helpers.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/helpers.js b/scripts/helpers.js index 1fc36f0b..983e1e93 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -46,8 +46,15 @@ function createModal(html, className, onclose, canclose) { } } close.addEventListener('click', removeModal); + let isHoldingMouseFromContent = false; + modal_content.addEventListener('mousedown', () => { + isHoldingMouseFromContent = true; + }); + document.addEventListener('mouseup', () => { + setTimeout(() => isHoldingMouseFromContent = false, 10); + }); modal.addEventListener('click', e => { - if(e.target === modal) { + if(e.target === modal && !isHoldingMouseFromContent) { if(!canclose || canclose()) removeModal(); } });