From: Alexander Ebert Date: Mon, 4 Apr 2022 17:01:12 +0000 (+0200) Subject: Verify that the active dialog is closable X-Git-Tag: 5.4.16_dev_1~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b5226eae1ea92c6d12118c378427ffc58987a60f;p=GitHub%2FWoltLab%2FWCF.git Verify that the active dialog is closable See https://www.woltlab.com/community/thread/294867-verschachtelte-dialoge-verwerfen-optionen-des-1-dialogs/ --- diff --git a/ts/WoltLabSuite/Core/Ui/Dialog.ts b/ts/WoltLabSuite/Core/Ui/Dialog.ts index 1f224ba331..80db4cdf7e 100644 --- a/ts/WoltLabSuite/Core/Ui/Dialog.ts +++ b/ts/WoltLabSuite/Core/Ui/Dialog.ts @@ -82,6 +82,13 @@ const UiDialog = { const target = event.target as HTMLElement; if (target.nodeName !== "INPUT" && target.nodeName !== "TEXTAREA") { const data = _dialogs.get(_activeDialog!) as DialogData; + + // The current dialog might be unclosable, but another open, but closable, + // dialog could have spawned this event listener. + if (!data.closable) { + return true; + } + if (typeof data.onBeforeClose === "function") { data.onBeforeClose(_activeDialog!); @@ -779,6 +786,13 @@ const UiDialog = { event.preventDefault(); const data = _dialogs.get(_activeDialog!) as DialogData; + + // The current dialog might be unclosable, but another open, but closable, + // dialog could have spawned this event listener. + if (!data.closable) { + return true; + } + if (typeof data.onBeforeClose === "function") { data.onBeforeClose(_activeDialog!); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js index fb27bbdea2..5fa45a5e8d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js @@ -64,6 +64,11 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S const target = event.target; if (target.nodeName !== "INPUT" && target.nodeName !== "TEXTAREA") { const data = _dialogs.get(_activeDialog); + // The current dialog might be unclosable, but another open, but closable, + // dialog could have spawned this event listener. + if (!data.closable) { + return true; + } if (typeof data.onBeforeClose === "function") { data.onBeforeClose(_activeDialog); return false; @@ -648,6 +653,11 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S _close(event) { event.preventDefault(); const data = _dialogs.get(_activeDialog); + // The current dialog might be unclosable, but another open, but closable, + // dialog could have spawned this event listener. + if (!data.closable) { + return true; + } if (typeof data.onBeforeClose === "function") { data.onBeforeClose(_activeDialog); return false;