Skip to content

Commit

Permalink
Set page to 1 in search when changing searchparams
Browse files Browse the repository at this point in the history
This is to fix a bug. Previously for example you have 100 searchresults
and you are on the last page, page 10. Then you add a facet to only show
results for year 1790 for example. Then you have one result but the
paging is still on page 10 and you see no results
  • Loading branch information
joschrew committed Feb 27, 2024
1 parent ddea174 commit 4dcb943
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/pages/search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
Advanced Search Fields
</button>
<extra-filters
v-show="showExtraFilters"
:extraFilters="extraFilters"
:onFilterChange="handleExtraFilterChange"
v-show="showExtraFilters"
:extraFilters="extraFilters"
:onFilterChange="handleExtraFilterChange"
/>
<div class="flex justify-end">
<button
v-show="showExtraFilters"
class="normal-blue-button"
@click="search"
>
Search
v-show="showExtraFilters"
class="normal-blue-button"
@click="search"
>
Search
</button>
</div>
<template v-if="hasResult">
Expand Down Expand Up @@ -71,7 +71,7 @@
<SearchResult :item="result"></SearchResult>
</div>
</div>
<Pagination :current="page" :total="total" @page-changed="current = $event" />
<Pagination :current="page" :total="total" />
</div>

<div class="border rounded-md bg-gray-50 flex flex-col">
Expand Down Expand Up @@ -202,7 +202,10 @@ export default {
}
this.$router.push({
name: "search",
query,
query: {
...query,
page: 1,
}
});
},
buttonClass(number) {
Expand Down Expand Up @@ -230,7 +233,10 @@ export default {
}
this.$router.push({
name: "search",
query: JSON.parse(JSON.stringify(query)),
query: {
...JSON.parse(JSON.stringify(query)),
page: 1
}
});
},
handlePageSizeChange(event) {
Expand Down

0 comments on commit 4dcb943

Please sign in to comment.