Verify that the active dialog is closable
authorAlexander Ebert <ebert@woltlab.com>
Mon, 4 Apr 2022 17:01:12 +0000 (19:01 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 4 Apr 2022 17:01:12 +0000 (19:01 +0200)
See https://www.woltlab.com/community/thread/294867-verschachtelte-dialoge-verwerfen-optionen-des-1-dialogs/

ts/WoltLabSuite/Core/Ui/Dialog.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js

index 1f224ba33165c684aee8b180904539ec02dcb48f..80db4cdf7ee52d733413697e3b6155a029b1ea22 100644 (file)
@@ -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!);
 
index fb27bbdea2cc7b60afcf0840bb90a7fdca950272..5fa45a5e8d635816586a6a56deb3c4e088b15df1 100644 (file)
@@ -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;