diff --git a/docs/src/.vuepress/store/index.js b/docs/src/.vuepress/store/index.js index cf84d1e..def1cdd 100644 --- a/docs/src/.vuepress/store/index.js +++ b/docs/src/.vuepress/store/index.js @@ -10,9 +10,11 @@ export default new Vuex.Store({ }, mutations: { openSearchModal(state) { + // console.log("opening modal") state.isSearchModalOpen = true; }, closeSearchModal(state) { + // console.log("closing modal") state.isSearchModalOpen = false; }, toggleLightMode(state) { diff --git a/docs/src/.vuepress/theme/components/SearchModal.vue b/docs/src/.vuepress/theme/components/SearchModal.vue index a0fad7d..ee65b6b 100644 --- a/docs/src/.vuepress/theme/components/SearchModal.vue +++ b/docs/src/.vuepress/theme/components/SearchModal.vue @@ -67,6 +67,10 @@ export default { return this.$site.themeConfig.searchPlaceholder || ""; }, + isModalOpen() { + return this.$store.state.isSearchModalOpen; + }, + showSuggestions() { return this.focused && this.suggestions && this.suggestions.length; }, @@ -185,7 +189,7 @@ export default { onEscapeKey(event) { if (event.key === "Escape" || event.keyCode === 27) { - this.$emit("close-modal"); + this.$store.commit("closeSearchModal"); } }, @@ -211,7 +215,7 @@ export default { }, 200); }, openModal() { - this.$emit("open-search-modal"); + this.$store.commit("openSearchModal"); }, getPageLocalePath(page) { @@ -271,7 +275,7 @@ export default { this.$router.push(this.suggestions[i].path); this.query = ""; this.focusIndex = 0; - this.$emit("close-modal"); + this.$store.commit("closeSearchModal"); }, focus(i) { diff --git a/docs/src/.vuepress/theme/layouts/Layout.vue b/docs/src/.vuepress/theme/layouts/Layout.vue index 93725b7..160c32a 100644 --- a/docs/src/.vuepress/theme/layouts/Layout.vue +++ b/docs/src/.vuepress/theme/layouts/Layout.vue @@ -66,7 +66,6 @@ export default { data() { return { isSidebarOpen: false, - showSearchModal: false, }; }, @@ -155,7 +154,7 @@ export default { event.preventDefault(); // Prevent default behavior // Check if modal is already open and toggle accordingly - if (this.showSearchModal) { + if (this.isSearchModalOpen) { this.closeSearchModal(); } else { this.openSearchModal(); @@ -167,11 +166,8 @@ export default { }, openSearchModal() { this.$store.commit('openSearchModal'); - this.showSearchModal = true; }, closeSearchModal() { - console.log("close modal") - this.showSearchModal = false; this.$store.commit('closeSearchModal'); },