Triggering the `cancel` event when the close button is clicked.
authorCyperghost <olaf_schmitz_1@t-online.de>
Mon, 13 May 2024 08:24:05 +0000 (10:24 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Mon, 13 May 2024 08:24:05 +0000 (10:24 +0200)
ts/WoltLabSuite/Core/Element/woltlab-core-dialog.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Element/woltlab-core-dialog.js

index 01aeca053703e8687309380811c1d69698ec263f..2e5a907a58f11a7d40365e2b2f115b5e67af7cb3 100644 (file)
@@ -261,6 +261,9 @@ export class WoltlabCoreDialogElement extends HTMLElement {
       closeButton.title = Language.get("wcf.dialog.button.close");
       closeButton.addEventListener("click", () => {
         if (this.#shouldClose()) {
+          const evt = new CustomEvent("cancel", { cancelable: false });
+          this.dispatchEvent(evt);
+
           this.close();
         }
       });
index 632bd30e3b46123e2cceeaa0b34b98817948459c..876f098da24b502570c74e3e63a0ea32c2c487d2 100644 (file)
@@ -200,6 +200,8 @@ define(["require", "exports", "tslib", "../Dom/Util", "../Helper/PageOverlay", "
                 closeButton.title = Language.get("wcf.dialog.button.close");
                 closeButton.addEventListener("click", () => {
                     if (this.#shouldClose()) {
+                        const evt = new CustomEvent("cancel", { cancelable: false });
+                        this.dispatchEvent(evt);
                         this.close();
                     }
                 });