From 655fda8e494df6f369e5c75298d9e2d860e66f1c Mon Sep 17 00:00:00 2001 From: dogle <15707274049@163.com> Date: Sun, 4 Oct 2026 19:53:58 +0800 Subject: [PATCH 1/4] fix: respect disabled prop on pagination items --- src/Pager.tsx | 5 +++- src/Pagination.tsx | 33 +++++++++++++------------ tests/__snapshots__/demo.test.tsx.snap | 34 ++++++++++++++++---------- tests/index.test.tsx | 10 ++++++++ 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/Pager.tsx b/src/Pager.tsx index 5a512afd..c1eb6f84 100644 --- a/src/Pager.tsx +++ b/src/Pager.tsx @@ -11,6 +11,7 @@ export interface PagerProps extends Pick { className?: string; style?: React.CSSProperties; showTitle: boolean; + disabled?: boolean; onClick?: (page: number) => void; onKeyPress?: ( e: React.KeyboardEvent, @@ -28,6 +29,7 @@ const Pager: React.FC = (props) => { className, style, showTitle, + disabled, onClick, onKeyPress, itemRender, @@ -68,10 +70,11 @@ const Pager: React.FC = (props) => { style={style} onClick={handleClick} onKeyDown={handleKeyPress} - tabIndex={0} + tabIndex={disabled ? null : 0} role="button" aria-label={pagerLabel} aria-current={active ? 'page' : undefined} + aria-disabled={disabled || undefined} > {pager} diff --git a/src/Pagination.tsx b/src/Pagination.tsx index 2ca06bd8..24825ec1 100644 --- a/src/Pagination.tsx +++ b/src/Pagination.tsx @@ -296,7 +296,7 @@ const Pagination: React.FC = (props) => { ), ); return React.isValidElement(prevButton) - ? React.cloneElement(prevButton, { disabled: !hasPrev }) + ? React.cloneElement(prevButton, { disabled: !hasPrev || disabled }) : prevButton; } @@ -312,7 +312,7 @@ const Pagination: React.FC = (props) => { ), ); return React.isValidElement(nextButton) - ? React.cloneElement(nextButton, { disabled: !hasNext }) + ? React.cloneElement(nextButton, { disabled: !hasNext || disabled }) : nextButton; } @@ -360,6 +360,7 @@ const Pagination: React.FC = (props) => { page: -1, className: paginationClassNames?.item, style: styles?.item, + disabled, }; const prevPage = current - 1 > 0 ? current - 1 : 0; @@ -377,7 +378,12 @@ const Pagination: React.FC = (props) => { if (goButton) { if (typeof goButton === 'boolean') { gotoButton = ( - ); @@ -476,7 +482,7 @@ const Pagination: React.FC = (props) => {
  • = (props) => { })} role="button" aria-label={prevItemTitle} + aria-disabled={disabled || undefined} > {jumpPrevContent}
  • @@ -493,7 +500,7 @@ const Pagination: React.FC = (props) => {
  • = (props) => { })} role="button" aria-label={nextItemTitle} + aria-disabled={disabled || undefined} > {jumpNextContent}
  • @@ -570,7 +578,7 @@ const Pagination: React.FC = (props) => { let prev = renderPrev(prevPage); if (isReactRenderable(prev)) { - const prevDisabled = !hasPrev || !allPages; + const prevDisabled = !hasPrev || !allPages || !!disabled; prev = (
  • = (props) => { let next = renderNext(nextPage); if (isReactRenderable(next)) { - let nextDisabled: boolean, nextTabIndex: number | null; - - if (simple) { - nextDisabled = !hasNext; - nextTabIndex = hasPrev ? 0 : null; - } else { - nextDisabled = !hasNext || !allPages; - nextTabIndex = nextDisabled ? null : 0; - } + const nextDisabled = !hasNext || !allPages || !!disabled; next = (
  • = (props) => { className={cls} style={style} ref={paginationRef} + aria-disabled={disabled || undefined} {...dataOrAriaAttributeProps} > {totalText} diff --git a/tests/__snapshots__/demo.test.tsx.snap b/tests/__snapshots__/demo.test.tsx.snap index 2b1ffd7e..11058e3c 100644 --- a/tests/__snapshots__/demo.test.tsx.snap +++ b/tests/__snapshots__/demo.test.tsx.snap @@ -2135,28 +2135,29 @@ exports[`Example jumper 1`] = ` 禁用