Skip to content

Commit

Permalink
Resolve negative counts in pagination (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonmcconnell authored Feb 7, 2025
1 parent edefffa commit 428d00d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eleven-spiders-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': patch
---

Resolve bug causing negative counts in pagination when there are fewer items than the per page count
2 changes: 1 addition & 1 deletion packages/svelte-ux/src/lib/components/Pagination.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
export let perPageOptions = [10, 25, 50, 100, 1000];
export let hideSinglePage = false;
export let format: (pagination: StoresValues<Pagination>) => string = (pagination) => {
return `${pagination.from.toLocaleString()}-${pagination.to.toLocaleString()} of ${pagination.total.toLocaleString()}`;
return `${Math.max(pagination.from, 0).toLocaleString()}-${pagination.to.toLocaleString()} of ${pagination.total.toLocaleString()}`;
};
type ShowComponent =
Expand Down

0 comments on commit 428d00d

Please sign in to comment.