From b5fc86f93dbba69f2bfdffd72c00a4a36a1b28a6 Mon Sep 17 00:00:00 2001
From: yoyo837 <6134547+yoyo837@users.noreply.github.com>
Date: Wed, 14 Oct 2026 21:23:49 +0800
Subject: [PATCH] fix: remove role="button" from li elements
role="button" on
inside violates axe aria-allowed-role and
list rules, which breaks downstream a11y test suites (e.g. antd CI on
every component rendering Pagination). Remove the invalid role while
keeping all a11y improvements from #690: aria-label, aria-current,
aria-disabled and keyboard activation.
---
src/Pager.tsx | 1 -
src/Pagination.tsx | 4 -
tests/__snapshots__/demo.test.tsx.snap | 287 +----------------------
tests/__snapshots__/simple.test.tsx.snap | 4 +-
tests/index.test.tsx | 11 +-
5 files changed, 9 insertions(+), 298 deletions(-)
diff --git a/src/Pager.tsx b/src/Pager.tsx
index 5a512afd..0deb2cc8 100644
--- a/src/Pager.tsx
+++ b/src/Pager.tsx
@@ -69,7 +69,6 @@ const Pager: React.FC = (props) => {
onClick={handleClick}
onKeyDown={handleKeyPress}
tabIndex={0}
- role="button"
aria-label={pagerLabel}
aria-current={active ? 'page' : undefined}
>
diff --git a/src/Pagination.tsx b/src/Pagination.tsx
index 2ca06bd8..e7037ab0 100644
--- a/src/Pagination.tsx
+++ b/src/Pagination.tsx
@@ -482,7 +482,6 @@ const Pagination: React.FC = (props) => {
[`${prefixCls}-jump-prev-custom-icon`]:
isReactRenderable(jumpPrevIcon),
})}
- role="button"
aria-label={prevItemTitle}
>
{jumpPrevContent}
@@ -499,7 +498,6 @@ const Pagination: React.FC = (props) => {
[`${prefixCls}-jump-next-custom-icon`]:
isReactRenderable(jumpNextIcon),
})}
- role="button"
aria-label={nextItemTitle}
>
{jumpNextContent}
@@ -581,7 +579,6 @@ const Pagination: React.FC = (props) => {
})}
style={styles?.item}
aria-disabled={prevDisabled}
- role="button"
aria-label={locale.prev_page}
>
{prev}
@@ -611,7 +608,6 @@ const Pagination: React.FC = (props) => {
})}
style={styles?.item}
aria-disabled={nextDisabled}
- role="button"
aria-label={locale.next_page}
>
{next}
diff --git a/tests/__snapshots__/demo.test.tsx.snap b/tests/__snapshots__/demo.test.tsx.snap
index 2b1ffd7e..e2c291c2 100644
--- a/tests/__snapshots__/demo.test.tsx.snap
+++ b/tests/__snapshots__/demo.test.tsx.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
+// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Example align 1`] = `
@@ -9,7 +9,6 @@ exports[`Example align 1`] = `
aria-disabled="true"
aria-label="上一页"
class="rc-pagination-prev rc-pagination-disabled"
- role="button"
>