mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
fix(pagination): page value should not exceed totalPages
This commit is contained in:
parent
6426bea7f2
commit
dd055e34d9
1 changed files with 7 additions and 3 deletions
|
@ -70,7 +70,7 @@
|
|||
/** Set an id for the top-level element */
|
||||
export let id = "ccs-" + Math.random().toString(36);
|
||||
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { afterUpdate, createEventDispatcher } from "svelte";
|
||||
import CaretLeft16 from "../icons/CaretLeft16.svelte";
|
||||
import CaretRight16 from "../icons/CaretRight16.svelte";
|
||||
import Button from "../Button/Button.svelte";
|
||||
|
@ -79,13 +79,17 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
afterUpdate(() => {
|
||||
if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
});
|
||||
|
||||
$: {
|
||||
if (typeof page !== "number") {
|
||||
page = Number(page);
|
||||
}
|
||||
|
||||
page = page > totalPages ? totalPages : page;
|
||||
|
||||
if (typeof pageSize !== "number") {
|
||||
pageSize = Number(pageSize);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue