mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(pagination): remove update event from afterUpdate cycle
It should only be called when page, pageSize values change after mounting.
This commit is contained in:
parent
0138910077
commit
458d1b52c8
1 changed files with 3 additions and 5 deletions
|
@ -91,7 +91,7 @@
|
|||
*/
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
|
||||
import { afterUpdate, createEventDispatcher } from "svelte";
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import CaretLeft16 from "carbon-icons-svelte/lib/CaretLeft16";
|
||||
import CaretRight16 from "carbon-icons-svelte/lib/CaretRight16";
|
||||
import { Button } from "../Button";
|
||||
|
@ -99,10 +99,6 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
afterUpdate(() => {
|
||||
dispatch("update", { pageSize, page });
|
||||
});
|
||||
|
||||
$: {
|
||||
if (typeof page !== "number") {
|
||||
page = Number(page);
|
||||
|
@ -111,6 +107,8 @@
|
|||
if (typeof pageSize !== "number") {
|
||||
pageSize = Number(pageSize);
|
||||
}
|
||||
|
||||
dispatch("update", { pageSize, page });
|
||||
}
|
||||
$: totalPages = Math.max(Math.ceil(totalItems / pageSize), 1);
|
||||
$: selectItems = Array.from({ length: totalPages }, (_, i) => i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue