diff options
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue b/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue index 5ab287150f2..9dc5c5db276 100644 --- a/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue +++ b/app/assets/javascripts/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue @@ -16,7 +16,7 @@ import createFlash from '~/flash'; import { __ } from '~/locale'; import { SortDirection } from './constants'; -import { stripQuotes, uniqueTokens } from './filtered_search_utils'; +import { filterEmptySearchTerm, stripQuotes, uniqueTokens } from './filtered_search_utils'; export default { components: { @@ -223,9 +223,14 @@ export default { // Put any searches that may have come in before // we fetched the saved searches ahead of the already saved ones - const resultantSearches = this.recentSearchesStore.setRecentSearches( + let resultantSearches = this.recentSearchesStore.setRecentSearches( this.recentSearchesStore.state.recentSearches.concat(searches), ); + // If visited URL has search params, add them to recent search store + if (filterEmptySearchTerm(this.filterValue).length) { + resultantSearches = this.recentSearchesStore.addRecentSearch(this.filterValue); + } + this.recentSearchesService.save(resultantSearches); this.recentSearches = resultantSearches; }); |