Skip to content

Commit 9e66821

Browse files
Resolve negative counts in paginationStore
1 parent 914f0f9 commit 9e66821

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/dry-mice-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@layerstack/svelte-stores': patch
3+
---
4+
5+
Resolve negative counts in paginationStore

packages/svelte-stores/src/lib/paginationStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function createState(_page: number, perPage: number, total: number) {
5050
page,
5151
perPage,
5252
total,
53-
from: Math.min(total, (page - 1) * perPage + 1),
53+
from: Math.min(total, Math.max(0, (page - 1) * perPage + 1)),
5454
to: Math.min(total, page * perPage),
5555

5656
totalPages,

0 commit comments

Comments
 (0)