Unset `uploadResolve`
authorCyperghost <olaf_schmitz_1@t-online.de>
Mon, 16 Dec 2024 12:13:59 +0000 (13:13 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Mon, 16 Dec 2024 12:13:59 +0000 (13:13 +0100)
ts/WoltLabSuite/Core/Form/Builder/Field/Controller/FileProcessor.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Controller/FileProcessor.js

index a22930b9080f849b6cfd9014b60a34c47e64705b..18e541f2b65ccaa1db38a743bbc35876e4402217 100644 (file)
@@ -67,7 +67,8 @@ export class FileProcessor {
 
     if (this.#simpleReplace) {
       this.#uploadButton.addEventListener("shouldUpload", () => {
-        const file = this.#uploadButton.parentElement!.querySelector("woltlab-core-file");
+        const file =
+          this.#uploadButton.parentElement!.querySelector<WoltlabCoreFileElement>("woltlab-core-file[file-id]");
         if (!file) {
           return;
         }
@@ -168,6 +169,7 @@ export class FileProcessor {
         this.#uploadButton.dataset.context = oldContext;
         this.#registerFile(this.#replaceElement!);
         this.#replaceElement = undefined;
+        this.#uploadResolve = undefined;
         this.#fileInput.removeEventListener("change", changeEventListener);
       };
 
@@ -216,6 +218,7 @@ export class FileProcessor {
     const oldContext = this.#startReplaceFile(oldFile);
 
     const cropCancelledEvent = () => {
+      this.#uploadResolve = undefined;
       this.#uploadButton.dataset.context = oldContext;
       this.#registerFile(this.#replaceElement!);
       this.#replaceElement = undefined;
index 6aac75c57af41b60df5ed521e0078760ffec337a..a9badcb066dd065abd276f9b78e073548f10a3af 100644 (file)
@@ -39,7 +39,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Language", "WoltLabSui
             this.#uploadButton = this.#container.querySelector("woltlab-core-file-upload");
             if (this.#simpleReplace) {
                 this.#uploadButton.addEventListener("shouldUpload", () => {
-                    const file = this.#uploadButton.parentElement.querySelector("woltlab-core-file");
+                    const file = this.#uploadButton.parentElement.querySelector("woltlab-core-file[file-id]");
                     if (!file) {
                         return;
                     }
@@ -123,6 +123,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Language", "WoltLabSui
                     this.#uploadButton.dataset.context = oldContext;
                     this.#registerFile(this.#replaceElement);
                     this.#replaceElement = undefined;
+                    this.#uploadResolve = undefined;
                     this.#fileInput.removeEventListener("change", changeEventListener);
                 };
                 this.#fileInput.addEventListener("cancel", cancelEventListener, { once: true });
@@ -163,6 +164,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Language", "WoltLabSui
         #simpleFileReplace(oldFile) {
             const oldContext = this.#startReplaceFile(oldFile);
             const cropCancelledEvent = () => {
+                this.#uploadResolve = undefined;
                 this.#uploadButton.dataset.context = oldContext;
                 this.#registerFile(this.#replaceElement);
                 this.#replaceElement = undefined;