From 824d12ba9a7ef2037fd11e4740aa117a1eaf8be8 Mon Sep 17 00:00:00 2001 From: Mats Bosson Date: Sun, 29 Mar 2026 08:53:07 +0700 Subject: [PATCH] Fix Pagination disabled guards --- packages/core/src/components/pagination/pagination-items.tsx | 5 +++-- packages/core/src/components/pagination/pagination-next.tsx | 3 ++- .../core/src/components/pagination/pagination-previous.tsx | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/pagination/pagination-items.tsx b/packages/core/src/components/pagination/pagination-items.tsx index 4dbe4eb..27fee13 100644 --- a/packages/core/src/components/pagination/pagination-items.tsx +++ b/packages/core/src/components/pagination/pagination-items.tsx @@ -1,5 +1,5 @@ import type { JSX } from "solid-js"; -import { For } from "solid-js"; +import { For, splitProps } from "solid-js"; import { usePaginationContext } from "./pagination-context"; /** Represents a single item in the pagination list. */ @@ -50,7 +50,8 @@ function buildItems(page: number, total: number, siblings: number): PaginationIt * Calculates which pages to show based on page, totalPages, and siblingCount. */ export function PaginationItems(props: PaginationItemsProps): JSX.Element { + const [local] = splitProps(props, ["children"]); const ctx = usePaginationContext(); const items = () => buildItems(ctx.page(), ctx.totalPages(), ctx.siblingCount()); - return {(item) => props.children(item)}; + return {(item) => local.children(item)}; } diff --git a/packages/core/src/components/pagination/pagination-next.tsx b/packages/core/src/components/pagination/pagination-next.tsx index ecbecd6..4478b69 100644 --- a/packages/core/src/components/pagination/pagination-next.tsx +++ b/packages/core/src/components/pagination/pagination-next.tsx @@ -15,8 +15,9 @@ export function PaginationNext(props: PaginationNextProps): JSX.Element { const isDisabled = () => ctx.page() >= ctx.totalPages(); const handleClick: JSX.EventHandler = (e) => { + if (isDisabled()) return; if (typeof local.onClick === "function") local.onClick(e); - if (!isDisabled()) ctx.onPageChange(ctx.page() + 1); + ctx.onPageChange(ctx.page() + 1); }; return ( diff --git a/packages/core/src/components/pagination/pagination-previous.tsx b/packages/core/src/components/pagination/pagination-previous.tsx index 904aa1d..0c3a877 100644 --- a/packages/core/src/components/pagination/pagination-previous.tsx +++ b/packages/core/src/components/pagination/pagination-previous.tsx @@ -15,8 +15,9 @@ export function PaginationPrevious(props: PaginationPreviousProps): JSX.Element const isDisabled = () => ctx.page() <= 1; const handleClick: JSX.EventHandler = (e) => { + if (isDisabled()) return; if (typeof local.onClick === "function") local.onClick(e); - if (!isDisabled()) ctx.onPageChange(ctx.page() - 1); + ctx.onPageChange(ctx.page() - 1); }; return (