diff --git a/src/dialogs/make-dialog-manager.ts b/src/dialogs/make-dialog-manager.ts index 942b7d751e41..2ad97ef2000e 100644 --- a/src/dialogs/make-dialog-manager.ts +++ b/src/dialogs/make-dialog-manager.ts @@ -125,25 +125,6 @@ export const showDialog = async ( return true; }; -export const showDialogFromHistory = async (dialogTag: string) => { - const dialogState = OPEN_DIALOG_STACK.find( - (state) => state.dialogTag === dialogTag - ); - if (dialogState) { - showDialog( - dialogState.element, - dialogState.root, - dialogTag, - dialogState.dialogParams, - dialogState.dialogImport, - false - ); - } else { - // remove the dialog from history if already closed - mainWindow.history.back(); - } -}; - export const closeDialog = async (dialogTag: string): Promise => { if (!(dialogTag in LOADED)) { return true; diff --git a/src/state/url-sync-mixin.ts b/src/state/url-sync-mixin.ts index 58594f844b35..2ed322f74d6f 100644 --- a/src/state/url-sync-mixin.ts +++ b/src/state/url-sync-mixin.ts @@ -1,10 +1,7 @@ /* eslint-disable no-console */ import type { PropertyValueMap, ReactiveElement } from "lit"; import { mainWindow } from "../common/dom/get_main_window"; -import { - closeLastDialog, - showDialogFromHistory, -} from "../dialogs/make-dialog-manager"; +import { closeLastDialog } from "../dialogs/make-dialog-manager"; import type { ProvideHassElement } from "../mixins/provide-hass-lit-mixin"; import type { Constructor } from "../types"; @@ -43,7 +40,9 @@ export const urlSyncMixin = < ): void { super.firstUpdated(changedProperties); if (mainWindow.history.state?.dialog) { - showDialogFromHistory(mainWindow.history.state.dialog); + // this is a page refresh with a dialog open + // the dialog stack must be empty in this case so this state should be cleaned up + mainWindow.history.back(); } } @@ -59,8 +58,8 @@ export const urlSyncMixin = < } if ("dialog" in ev.state) { // coming to a dialog - // in practice the dialog stack is empty when navigating forward, so this is a no-op - showDialogFromHistory(ev.state.dialog); + // the dialog stack must be empty in this case so this state should be cleaned up + mainWindow.history.back(); } } };