Skip to content

Commit bd8fa38

Browse files
committed
fix: cap pagination page count to max fetchable results (#1923)
1 parent 6e345ad commit bd8fa38

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/pages/search.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ const effectiveTotal = computed(() => {
265265
return displayResults.value.length
266266
})
267267
268+
/**
269+
* Total items for pagination purposes.
270+
* Capped by EAGER_LOAD_SIZE so that the page count only reflects pages we can
271+
* actually fetch — e.g. with a 500-result cap, max pages = ceil(500 / pageSize).
272+
* Without this cap, a search returning total=92,000 would show 3,680 pages but
273+
* navigation beyond page 20 (at 25/page) would silently fail.
274+
*/
275+
const paginationTotal = computed(() => {
276+
const cap = EAGER_LOAD_SIZE[searchProvider.value]
277+
return Math.min(effectiveTotal.value, cap)
278+
})
279+
268280
// Handle filter chip removal
269281
function handleClearFilter(chip: FilterChip) {
270282
clearFilter(chip)
@@ -878,7 +890,7 @@ onBeforeUnmount(() => {
878890
v-model:mode="paginationMode"
879891
v-model:page-size="preferredPageSize"
880892
v-model:current-page="currentPage"
881-
:total-items="effectiveTotal"
893+
:total-items="paginationTotal"
882894
:view-mode="viewMode"
883895
/>
884896
</div>

0 commit comments

Comments
 (0)