From a6632b750d739265a200eb4b908917930664e35c Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Wed, 17 Apr 2024 10:54:13 +0200 Subject: [PATCH] Fix pagination overlow when changing the number of rows per page by a bigger value --- frontend/src/lib/components/ModelTable/RowsPerPage.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/lib/components/ModelTable/RowsPerPage.svelte b/frontend/src/lib/components/ModelTable/RowsPerPage.svelte index 8378067ef..51081847c 100644 --- a/frontend/src/lib/components/ModelTable/RowsPerPage.svelte +++ b/frontend/src/lib/components/ModelTable/RowsPerPage.svelte @@ -3,7 +3,12 @@ import * as m from '$paraglide/messages'; export let handler: DataHandler; const rowsPerPage = handler.getRowsPerPage(); + const rowCount = handler.getRowCount(); const options = [5, 10, 20, 50, 100]; + + $: if ($rowCount.start >= $rowCount.total && $rowsPerPage) { + handler.setPage(Math.ceil($rowCount.total / $rowsPerPage)); + }