mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(pagination): convert page variable to number type
The Select component coerces the page value into a string, which affects other components.
This commit is contained in:
parent
192f98dc5d
commit
0138910077
2 changed files with 17 additions and 2 deletions
|
@ -12,6 +12,12 @@
|
|||
{:else if story === 'skeleton'}
|
||||
<PaginationSkeleton />
|
||||
{:else}
|
||||
<Pagination {...$$props}>Pagination</Pagination>
|
||||
<Pagination
|
||||
{...$$props}
|
||||
on:update="{({ detail }) => {
|
||||
console.log(detail);
|
||||
}}">
|
||||
Pagination
|
||||
</Pagination>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
@ -100,9 +100,18 @@
|
|||
const dispatch = createEventDispatcher();
|
||||
|
||||
afterUpdate(() => {
|
||||
dispatch("update", { pageSize: parseInt(pageSize), page: parseInt(page) });
|
||||
dispatch("update", { pageSize, page });
|
||||
});
|
||||
|
||||
$: {
|
||||
if (typeof page !== "number") {
|
||||
page = Number(page);
|
||||
}
|
||||
|
||||
if (typeof pageSize !== "number") {
|
||||
pageSize = Number(pageSize);
|
||||
}
|
||||
}
|
||||
$: totalPages = Math.max(Math.ceil(totalItems / pageSize), 1);
|
||||
$: selectItems = Array.from({ length: totalPages }, (_, i) => i);
|
||||
$: backButtonDisabled = disabled || page === 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue