From 7fdc1358a8c2481200c952d5839d15c3fa1aca7f Mon Sep 17 00:00:00 2001 From: Andrej Date: Mon, 13 May 2024 17:11:49 +0200 Subject: [PATCH] Fix loading full view for global search results [SCI-10697] --- .../vue/global_search/groups/search_mixin.js | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/javascript/vue/global_search/groups/search_mixin.js b/app/javascript/vue/global_search/groups/search_mixin.js index e14c1e3c6..7992c6dfd 100644 --- a/app/javascript/vue/global_search/groups/search_mixin.js +++ b/app/javascript/vue/global_search/groups/search_mixin.js @@ -112,8 +112,10 @@ export default { loadData() { if (this.query.length < 2) return; - if (this.loading && this.page) return; + if (this.loading && this.page && !(this.selected && !this.fullDataLoaded)) return; + const fullView = this.selected; + const currentPage = this.page; this.loading = true; axios.get(this.searchUrl, { params: { @@ -121,21 +123,26 @@ export default { sort: this.sort, filters: this.filters, group: this.group, - preview: !this.selected, - page: this.page + preview: !fullView, + page: currentPage } }) .then((response) => { if (this.selected) this.fullDataLoaded = true; - this.results = this.results.concat(response.data.data); - this.total = response.data.meta.total; - this.disabled = response.data.meta.disabled; - this.loading = false; - this.page = response.data.meta.next_page; + + if (this.selected === fullView && this.page === currentPage) { + this.results = this.results.concat(response.data.data); + this.total = response.data.meta.total; + this.disabled = response.data.meta.disabled; + this.loading = false; + this.page = response.data.meta.next_page; + } }) .finally(() => { - this.loading = false; - this.$emit('updated'); + if (this.selected === fullView) { + this.loading = false; + this.$emit('updated'); + } }); } }