diff --git a/docs/common/DocsLibraryLink.vue b/docs/common/DocsLibraryLink.vue index 8377730a0..830e8527c 100644 --- a/docs/common/DocsLibraryLink.vue +++ b/docs/common/DocsLibraryLink.vue @@ -1,8 +1,8 @@ @@ -17,6 +17,15 @@ required: true, }, }, + computed: { + computedLink() { + // Preserve query parameters in the link + return { + path: '/' + this.component.toLowerCase(), + query: { ...this.$route.query }, + }; + }, + }, }; diff --git a/docs/common/DocsPageTemplate/SideNav/NavLink.vue b/docs/common/DocsPageTemplate/SideNav/NavLink.vue index d3be54076..83ee72e8b 100644 --- a/docs/common/DocsPageTemplate/SideNav/NavLink.vue +++ b/docs/common/DocsPageTemplate/SideNav/NavLink.vue @@ -7,14 +7,15 @@ > {{ page.title }} - {{ page.title }} - + @@ -39,6 +40,13 @@ currentPage() { return this.page.path === this.$route.path; }, + computedLink() { + // Preserve query parameters in the link + return { + path: this.page.path, + query: { ...this.$route.query }, + }; + }, }, }; diff --git a/docs/common/DocsPageTemplate/SideNav/index.vue b/docs/common/DocsPageTemplate/SideNav/index.vue index 8a66d9619..a72872daa 100644 --- a/docs/common/DocsPageTemplate/SideNav/index.vue +++ b/docs/common/DocsPageTemplate/SideNav/index.vue @@ -77,22 +77,42 @@ return toc; }, }, + watch: { filterText(newValue) { if (window) { - window.sessionStorage.setItem('nav-filter', newValue); + //Clear the filter query when filtertext is empty + if (!newValue) { + this.$router.push({ path: this.$route.path, query: {} }); + } else { + //else ,update the filter query param + this.$router.push({ + path: this.$route.path, + query: { ...this.$route.query, filter: newValue }, + }); + } } }, }, mounted() { if (window) { - const filterText = window.sessionStorage.getItem('nav-filter'); - if (filterText) { - this.filterText = filterText; + const { filter } = this.$route.query; + // Set filterText from the query parameter if it exists + if (filter) { + this.filterText = filter; } this.$refs.links.scrollTop = window.sessionStorage.getItem('nav-scroll'); + // Restoring filter state when a user navigates back + window.addEventListener('popstate', event => { + if (event.state && 'filterText' in event.state) { + this.filterText = event.state.filterText; + } else { + this.filterText = ''; // Reset if no filterText is in state + } + }); } - // don't show the nav until the state is set + + // Don't show the nav until the state is set this.loaded = true; }, methods: {