From 4b7fa7a543aaf53326c9a554285be67c4487856b Mon Sep 17 00:00:00 2001 From: advplyr Date: Tue, 17 Jan 2023 17:47:29 -0600 Subject: [PATCH] Fix:Clearing filter refreshes library --- components/bookshelf/LazyBookshelf.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/bookshelf/LazyBookshelf.vue b/components/bookshelf/LazyBookshelf.vue index d0def2a6..347301f8 100644 --- a/components/bookshelf/LazyBookshelf.vue +++ b/components/bookshelf/LazyBookshelf.vue @@ -371,15 +371,16 @@ export default { return searchParams.toString() }, checkUpdateSearchParams() { - var newSearchParams = this.buildSearchParams() - var currentQueryString = window.location.search + const newSearchParams = this.buildSearchParams() + let currentQueryString = window.location.search if (currentQueryString && currentQueryString.startsWith('?')) currentQueryString = currentQueryString.slice(1) - if (newSearchParams === '') { + if (newSearchParams === '' && !currentQueryString) { return false } if (newSearchParams !== this.currentSFQueryString || newSearchParams !== currentQueryString) { - let newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?' + newSearchParams + const queryString = newSearchParams ? `?${newSearchParams}` : '' + let newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + queryString window.history.replaceState({ path: newurl }, '', newurl) this.routeFullPath = window.location.pathname + (window.location.search || '') // Update for saving scroll position @@ -389,7 +390,7 @@ export default { return false }, settingsUpdated(settings) { - var wasUpdated = this.checkUpdateSearchParams() + const wasUpdated = this.checkUpdateSearchParams() if (wasUpdated) { this.resetEntities() }