Prevent closing unclosable dialogs with the escape key
authorAlexander Ebert <ebert@woltlab.com>
Wed, 27 Jul 2022 17:18:27 +0000 (19:18 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 27 Jul 2022 17:18:27 +0000 (19:18 +0200)
See https://www.woltlab.com/community/thread/296571-esc-schlie%C3%9Ft-login-dialog-im-acp/

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

index 7f1803cf6a6e4df464743748bc02a5c662bb63f0..001faf43f24e90f727dc07b05098a7982e77475c 100644 (file)
@@ -506,7 +506,10 @@ const UiDialog = {
     const focusTrap = createFocusTrap(dialog, {
       allowOutsideClick: true,
       escapeDeactivates(): boolean {
-        UiDialog.close(id);
+        const data = _dialogs.get(id)!;
+        if (data.closable) {
+          UiDialog.close(id);
+        }
 
         return false;
       },
index bce4026c394cf88d4614225084020991ce1be3ce..9c65768c13548a3bee49b3827e9284ea6b428976 100644 (file)
@@ -422,7 +422,10 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S
             const focusTrap = (0, focus_trap_1.createFocusTrap)(dialog, {
                 allowOutsideClick: true,
                 escapeDeactivates() {
-                    UiDialog.close(id);
+                    const data = _dialogs.get(id);
+                    if (data.closable) {
+                        UiDialog.close(id);
+                    }
                     return false;
                 },
                 fallbackFocus: dialog,