Move closingPrevented to a property

367da588cd8356245a71ab2a534e67596ac51886

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +4 -1Ignore whitespace
public/scripts/popup.js+4 -1
@@ -135,6 +135,7 @@ export class Popup {
135135
136136 /** @type {Promise<any>} */ #promise;
137137 /** @type {(result: any) => any} */ #resolver;
138+ /** @type {boolean} */ #isClosingPrevented;
138139
139140 /**
140141 * Constructs a new Popup object with the given text content, type, inputValue, and options
@@ -342,7 +343,7 @@ export class Popup {
342343 // It seems to just call 'close' on the dialog even if the 'cancel' event was prevented.
343344 // Here, we just say that close should not happen if the dalog has no result.
344345 const closeListener = async (evt) => {
345346 if (this.result === undefined#isClosingPrevented) {
346347 evt.preventDefault();
347348 evt.stopPropagation();
348349 this.dlg.showModal();
@@ -495,6 +496,7 @@ export class Popup {
495496 if (this.onClosing) {
496497 const shouldClose = this.onClosing(this);
497498 if (!shouldClose) {
499+ this.#isClosingPrevented = true;
498500 // Set values back if we cancel out of closing the popup
499501 this.value = undefined;
500502 this.result = undefined;
@@ -502,6 +504,7 @@ export class Popup {
502504 return undefined;
503505 }
504506 }
507+ this.#isClosingPrevented = false;
505508
506509 Popup.util.lastResult = { value, result, inputResults: this.inputResults };
507510 this.#hide();