Skip to content

Commit ae0676e

Browse files
authored
Reset pagination when changing search filters (#56164)
1 parent e064536 commit ae0676e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/search/components/results/Aggregations.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ export function SearchResultsAggregations({ aggregations }: Props) {
3030
} else {
3131
params.append('toplevel', toplevel)
3232
}
33+
// Reset pagination when filters change to prevent showing 0 results
34+
params.delete('page')
3335
return `/${locale}${asPathRoot}?${params}`
3436
}
3537

3638
function makeClearHref() {
3739
const [asPathRoot, asPathQuery = ''] = asPath.split('#')[0].split('?')
3840
const params = new URLSearchParams(asPathQuery)
3941
params.delete('toplevel')
42+
// Reset pagination when clearing filters
43+
params.delete('page')
4044
return `/${locale}${asPathRoot}?${params}`
4145
}
4246

0 commit comments

Comments
 (0)