From 48d9002544fa2ff0c4ed5379ade9c773b8307dc0 Mon Sep 17 00:00:00 2001 From: Aidan Perry <31855485+UltraSive@users.noreply.github.com> Date: Thu, 12 Sep 2024 08:53:35 -0500 Subject: [PATCH] fix: call `onPageChange` after setting the `page` (#657) Co-authored-by: Hunter Johnston <64506580+huntabyte@users.noreply.github.com> --- .changeset/plenty-pears-add.md | 5 +++++ .../src/lib/bits/pagination/components/pagination.svelte | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/plenty-pears-add.md diff --git a/.changeset/plenty-pears-add.md b/.changeset/plenty-pears-add.md new file mode 100644 index 000000000..3e60ace1a --- /dev/null +++ b/.changeset/plenty-pears-add.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +fix(Pagination): call `onPageChange` _after_ setting the `page` diff --git a/packages/bits-ui/src/lib/bits/pagination/components/pagination.svelte b/packages/bits-ui/src/lib/bits/pagination/components/pagination.svelte index 01cd609e8..14e872182 100644 --- a/packages/bits-ui/src/lib/bits/pagination/components/pagination.svelte +++ b/packages/bits-ui/src/lib/bits/pagination/components/pagination.svelte @@ -25,8 +25,8 @@ defaultPage: page, onPageChange: ({ next }) => { if (page !== next) { - onPageChange?.(next); page = next; + onPageChange?.(next); } return next;