mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Move closingPrevented to a property
This commit is contained in:
@@ -135,6 +135,7 @@ export class Popup {
|
|||||||
|
|
||||||
/** @type {Promise<any>} */ #promise;
|
/** @type {Promise<any>} */ #promise;
|
||||||
/** @type {(result: any) => any} */ #resolver;
|
/** @type {(result: any) => any} */ #resolver;
|
||||||
|
/** @type {boolean} */ #isClosingPrevented;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Popup object with the given text content, type, inputValue, and options
|
* Constructs a new Popup object with the given text content, type, inputValue, and options
|
||||||
@@ -342,7 +343,7 @@ export class Popup {
|
|||||||
// It seems to just call 'close' on the dialog even if the 'cancel' event was prevented.
|
// It seems to just call 'close' on the dialog even if the 'cancel' event was prevented.
|
||||||
// Here, we just say that close should not happen if the dalog has no result.
|
// Here, we just say that close should not happen if the dalog has no result.
|
||||||
const closeListener = async (evt) => {
|
const closeListener = async (evt) => {
|
||||||
if (this.result === undefined) {
|
if (this.#isClosingPrevented) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
this.dlg.showModal();
|
this.dlg.showModal();
|
||||||
@@ -495,6 +496,7 @@ export class Popup {
|
|||||||
if (this.onClosing) {
|
if (this.onClosing) {
|
||||||
const shouldClose = this.onClosing(this);
|
const shouldClose = this.onClosing(this);
|
||||||
if (!shouldClose) {
|
if (!shouldClose) {
|
||||||
|
this.#isClosingPrevented = true;
|
||||||
// Set values back if we cancel out of closing the popup
|
// Set values back if we cancel out of closing the popup
|
||||||
this.value = undefined;
|
this.value = undefined;
|
||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
@@ -502,6 +504,7 @@ export class Popup {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.#isClosingPrevented = false;
|
||||||
|
|
||||||
Popup.util.lastResult = { value, result, inputResults: this.inputResults };
|
Popup.util.lastResult = { value, result, inputResults: this.inputResults };
|
||||||
this.#hide();
|
this.#hide();
|
||||||
|
Reference in New Issue
Block a user