Repository navigation
fix: remove role="button" from li elements #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,7 +482,6 @@ const Pagination: React.FC<PaginationProps> = (props) => { | |
| [`${prefixCls}-jump-prev-custom-icon`]: | ||
| isReactRenderable(jumpPrevIcon), | ||
| })} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reasoning as my reply on the |
||
| role="button" | ||
| aria-label={prevItemTitle} | ||
| > | ||
| {jumpPrevContent} | ||
|
|
@@ -499,7 +498,6 @@ const Pagination: React.FC<PaginationProps> = (props) => { | |
| [`${prefixCls}-jump-next-custom-icon`]: | ||
| isReactRenderable(jumpNextIcon), | ||
| })} | ||
| role="button" | ||
| aria-label={nextItemTitle} | ||
| > | ||
| {jumpNextContent} | ||
|
|
@@ -581,7 +579,6 @@ const Pagination: React.FC<PaginationProps> = (props) => { | |
| })} | ||
| style={styles?.item} | ||
| aria-disabled={prevDisabled} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reasoning as my reply on the |
||
| role="button" | ||
| aria-label={locale.prev_page} | ||
| > | ||
| {prev} | ||
|
|
@@ -611,7 +608,6 @@ const Pagination: React.FC<PaginationProps> = (props) => { | |
| })} | ||
| style={styles?.item} | ||
| aria-disabled={nextDisabled} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same reasoning as my reply on the |
||
| role="button" | ||
| aria-label={locale.next_page} | ||
| > | ||
| {next} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid concern — this is exactly the tradeoff #690 tried to solve when it added the role. However,
role="button"on an<li>inside<ul>is not allowed by ARIA in HTML, so the v1.5/1.6 markup cannot ship in any axe-gated downstream: antd's CI fails 5 test jobs overaria-allowed-role+liston every component rendering Pagination (ant-design/ant-design#58604).Moving focus/handlers onto a real
<button>inside the<li>cannot be done unconditionally, becauseitemRenderreturns arbitrary nodes (links, icons,null) that cannot be nested inside a<button>. The dual-path approach — native<button>only when the default render is used, li-as-control otherwise (also suggested by CodeRabbit below) — is a sound future direction, but it changes the DOM/CSS contract for the default case (downstream styles target thelidirectly) and doubles the behavior matrix, so I'd keep it out of this compliance-fix patch.This PR restores the pre-1.5.0 state (a bare focusable
<li>, which shipped for years) while keeping every #690 improvement —aria-label,aria-current="page",aria-disabled, Enter/Space activation — so assistive-tech users get strictly more information than v1.4.x, without the spec violation.Happy to follow up with the dual-path in a separate PR if that's the preferred direction.