Move closingPrevented to a property
| @@ -135,6 +135,7 @@ export class Popup { | ||
| 135 | 135 | |
| 136 | 136 | /** @type {Promise<any>} */ #promise; |
| 137 | 137 | /** @type {(result: any) => any} */ #resolver; |
| 138 | + /** @type {boolean} */ #isClosingPrevented; | |
| 138 | 139 | |
| 139 | 140 | /** |
| 140 | 141 | * Constructs a new Popup object with the given text content, type, inputValue, and options |
| @@ -342,7 +343,7 @@ export class Popup { | ||
| 342 | 343 | // It seems to just call 'close' on the dialog even if the 'cancel' event was prevented. |
| 343 | 344 | // Here, we just say that close should not happen if the dalog has no result. |
| 344 | 345 | const closeListener = async (evt) => { |
| 345 | 346 | if (this.result === undefined#isClosingPrevented) { |
| 346 | 347 | evt.preventDefault(); |
| 347 | 348 | evt.stopPropagation(); |
| 348 | 349 | this.dlg.showModal(); |
| @@ -495,6 +496,7 @@ export class Popup { | ||
| 495 | 496 | if (this.onClosing) { |
| 496 | 497 | const shouldClose = this.onClosing(this); |
| 497 | 498 | if (!shouldClose) { |
| 499 | + this.#isClosingPrevented = true; | |
| 498 | 500 | // Set values back if we cancel out of closing the popup |
| 499 | 501 | this.value = undefined; |
| 500 | 502 | this.result = undefined; |
| @@ -502,6 +504,7 @@ export class Popup { | ||
| 502 | 504 | return undefined; |
| 503 | 505 | } |
| 504 | 506 | } |
| 507 | + this.#isClosingPrevented = false; | |
| 505 | 508 | |
| 506 | 509 | Popup.util.lastResult = { value, result, inputResults: this.inputResults }; |
| 507 | 510 | this.#hide(); |