From c89973032bf81f9778af2e6c6c304dbf5f810936 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Thu, 7 Sep 2023 16:06:17 +0200 Subject: [PATCH] Fix: Close mobile menu when navigating --- resources/js/stores/menuStore.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/js/stores/menuStore.js b/resources/js/stores/menuStore.js index 523f534e..db01d72a 100644 --- a/resources/js/stores/menuStore.js +++ b/resources/js/stores/menuStore.js @@ -1,4 +1,5 @@ import {defineStore} from 'pinia'; +import {router} from '@inertiajs/vue3'; export const menuStore = defineStore('menu', { state: () => ({ @@ -28,15 +29,13 @@ export const menuStore = defineStore('menu', { this.tooltipsVisible = !window.matchMedia('(min-width: 1280px)').matches; }, startInertiaListener() { - var _self = this; - window.addEventListener('resize', this.menuListener); this.menuListener(); - window.addEventListener('inertia:start', () => { + router.on('before', () => { if (!window.matchMedia('(min-width: 1024px)').matches) { - _self.visible = false; - _self.overflowVisible = false; + this.visible = false; + this.overflowVisible = false; } }); },