From 29897fa43e5693391246ac2f7f9c08084e39a281 Mon Sep 17 00:00:00 2001 From: Sascha Bieberstein Date: Thu, 27 Jun 2024 12:48:57 +0200 Subject: [PATCH] Prevent closing when click is dragged from within overlay to background The previous behaviour is a result of this caveat of the click event: If the button is pressed on one element and the pointer is moved outside the element before the button is released, the event is fired on the most specific ancestor element that contained both elements. So if a click started within the overlay content and was dragged outside of it to the background (which can happen by accident when content with drag support is displayed inside the overlay) the overlay would suddenly close. We now use the mousdown event so it only triggers when the click is started outside of the overlay content. Tested on Desktop Chrome, Android Chrome & IE 11. Fixes: OX-11077 --- .../resources/default/assets/common/scripts/overlay.js.pasta | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/default/assets/common/scripts/overlay.js.pasta b/src/main/resources/default/assets/common/scripts/overlay.js.pasta index d587efb85..c7206faca 100644 --- a/src/main/resources/default/assets/common/scripts/overlay.js.pasta +++ b/src/main/resources/default/assets/common/scripts/overlay.js.pasta @@ -15,6 +15,7 @@ */ let _overlay = null; let shouldEscClose = null; + let LEFT_MOUSE_BUTTON_CODE = 0; /**@ * Creates a new (hidden) overlay. This can be made visible to the user afterwards by calling `overlay.showOverlay`. @@ -79,8 +80,8 @@ } if (yieldable) { - _overlay.addEventListener('click', function (event) { - if (event.target === _overlay) { + _overlay.addEventListener('mousedown', function (event) { + if (event.button === LEFT_MOUSE_BUTTON_CODE && event.target === _overlay) { sirius.dispatchEvent('sci-overlay-dismissed'); overlay.destroyOverlay(); }