From 332f591ebb657d0bc7a8c66a8f47a4317c502728 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 16 Aug 2023 11:26:52 +0530 Subject: [PATCH 1/2] Fixed: issue of menu not being enabled for the correct page when using the back button in Import App --- src/components/Menu.vue | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 3068b768..8e8f3f68 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -11,7 +11,6 @@ { - return page.url === this.$router.currentRoute.value.path; - }) - }, computed: { ...mapGetters({ isUserAuthenticated: 'user/isUserAuthenticated', @@ -87,18 +80,9 @@ export default defineComponent({ userProfile: 'user/getUserProfile' }) }, - watch:{ - $route (to) { - // When logout and login it should point to Oth index - // TODO Find a better way - if (to.path === '/login') { - this.selectedIndex = 0; - } - }, - }, setup() { const store = useStore(); - const selectedIndex = ref(0); + const router = useRouter(); const appPages = [ { title: "Inventory", @@ -123,8 +107,14 @@ export default defineComponent({ url: "/settings", iosIcon: settings, mdIcon: settings, - }, - ]; + } + ] as any; + + const selectedIndex = computed(() => { + const path = router.currentRoute.value.path + return appPages.findIndex((screen : any) => screen.url === path || screen.childRoutes?.includes(path)) + }) + return { selectedIndex, appPages, @@ -133,7 +123,7 @@ export default defineComponent({ settings, store }; - }, + } });