Skip to content

Commit 49bddf6

Browse files
authored
Automation add TCA: fix: prevent multiple dialog closures by tracking closing state (#28978)
1 parent 0daf94e commit 49bddf6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/panels/config/automation/add-automation-element-dialog.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ class DialogAddAutomationElement
232232

233233
private _configEntryLookup: Record<string, ConfigEntry> = {};
234234

235+
private _closing = false;
236+
235237
// #endregion variables
236238

237239
// #region lifecycle
@@ -347,6 +349,8 @@ class DialogAddAutomationElement
347349
}
348350
}
349351

352+
this._closing = true;
353+
350354
// if dialog is closed, but root level isn't active, clean up history state
351355
if (mainWindow.history.state?.dialogData) {
352356
this._open = false;
@@ -360,6 +364,7 @@ class DialogAddAutomationElement
360364
fireEvent(this, "dialog-closed", { dialog: this.localName });
361365
}
362366
this._open = true;
367+
this._closing = false;
363368
this._params = undefined;
364369
this._selectedCollectionIndex = undefined;
365370
this._selectedGroup = undefined;
@@ -1875,7 +1880,10 @@ class DialogAddAutomationElement
18751880
}
18761881

18771882
private _handleClosed() {
1878-
this.closeDialog();
1883+
// if closing isn't already in progress, close the dialog
1884+
if (!this._closing) {
1885+
this.closeDialog();
1886+
}
18791887
}
18801888

18811889
// #region interaction

0 commit comments

Comments
 (0)