From 178ad2dffa53a9f90700113961c6d02b5c958b77 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Thu, 13 Apr 2023 21:16:59 +0200 Subject: [PATCH] Fix back button when directly opening subview (#16145) --- src/panels/lovelace/hui-root.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/panels/lovelace/hui-root.ts b/src/panels/lovelace/hui-root.ts index 58825d76ab..6fda17d966 100644 --- a/src/panels/lovelace/hui-root.ts +++ b/src/panels/lovelace/hui-root.ts @@ -742,12 +742,14 @@ class HUIRoot extends LitElement { const curViewConfig = typeof this._curView === "number" ? views[this._curView] : undefined; - if (curViewConfig?.back_path) { - navigate(curViewConfig.back_path); + if (curViewConfig?.back_path != null) { + navigate(curViewConfig.back_path, { replace: true }); } else if (history.length > 1) { history.back(); + } else if (!views[0].subview) { + navigate(this.route!.prefix, { replace: true }); } else { - navigate(this.route!.prefix); + navigate("/"); } }