From 95dc62f875f3038035f684b5b5c26c614fc06d9b Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 10 Dec 2023 21:55:28 +0100 Subject: [PATCH] Fix navigation issues with model cards Fixes #2196. Reverts #2074. I have tried messing around with the browser history manually to fix that issue, however trying several approaches, none worked perfect. This is the best solution I could come up with, it at least remembers which tab you had opened when you navigate back to the home page from any other page. Signed-off-by: Florian Hotze --- .../web/src/components/cards/card-mixin.js | 1 - bundles/org.openhab.ui/web/src/js/routes.js | 40 +------------------ bundles/org.openhab.ui/web/src/pages/home.vue | 7 ++-- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/cards/card-mixin.js b/bundles/org.openhab.ui/web/src/components/cards/card-mixin.js index 0547a4667d..3ebde15ba0 100644 --- a/bundles/org.openhab.ui/web/src/components/cards/card-mixin.js +++ b/bundles/org.openhab.ui/web/src/components/cards/card-mixin.js @@ -78,7 +78,6 @@ export default { setTimeout(() => { this.$f7.card.close(this.$refs.card.$el) }, 100) }, back (evt) { - console.debug(evt.state) if (!evt.state || evt.state.cardId === this.cardId) return if (this.opened) this.closeCard() } diff --git a/bundles/org.openhab.ui/web/src/js/routes.js b/bundles/org.openhab.ui/web/src/js/routes.js index 820ac1725d..ec8c0403f4 100644 --- a/bundles/org.openhab.ui/web/src/js/routes.js +++ b/bundles/org.openhab.ui/web/src/js/routes.js @@ -92,45 +92,7 @@ export default [ // keepAlive: true, options: { transition: 'f7-dive' - }, - routes: [ - { - path: 'overview', - component: HomePage, - options: { - props: { - initialTab: 'overview' - } - } - }, - { - path: 'locations', - component: HomePage, - options: { - props: { - initialTab: 'locations' - } - } - }, - { - path: 'equipment', - component: HomePage, - options: { - props: { - initialTab: 'equipment' - } - } - }, - { - path: 'properties', - component: HomePage, - options: { - props: { - initialTab: 'properties' - } - } - } - ] + } }, { path: '/page/:uid', diff --git a/bundles/org.openhab.ui/web/src/pages/home.vue b/bundles/org.openhab.ui/web/src/pages/home.vue index e9db13edc6..685e720d06 100644 --- a/bundles/org.openhab.ui/web/src/pages/home.vue +++ b/bundles/org.openhab.ui/web/src/pages/home.vue @@ -88,7 +88,6 @@ import ModelTab from './home/model-tab.vue' import HomeCards from './home/homecards-mixin' export default { - props: ['initialTab'], mixins: [HomeCards], components: { OverviewTab, @@ -101,7 +100,7 @@ export default { showCards: false, showPinToHome: false, showExitToApp: false, - currentTab: this.initialTab || 'overview', + currentTab: this.$f7.data.currentHomeTab || 'overview', overviewPageKey: this.$utils.id(), items: [] } @@ -165,7 +164,7 @@ export default { }, methods: { onPageBeforeIn () { - this.$f7router.updateCurrentUrl('/' + this.currentTab) + this.$f7.data.currentHomeTab = this.currentTab this.overviewPageKey = this.$utils.id() }, onPageAfterIn () { @@ -176,6 +175,7 @@ export default { }, onPageBeforeOut () { this.$store.dispatch('stopTrackingStates') + this.$f7.data.currentHomeTab = this.currentTab }, onPageInit () { this.$store.subscribe((mutation, state) => { @@ -197,7 +197,6 @@ export default { }, switchTab (tab) { this.currentTab = tab - this.$f7router.updateCurrentUrl('/' + this.currentTab) }, tabVisible (tab) { if (!this.tabsVisible) return false