Skip to content

Commit

Permalink
fix(Pagination): Use anchor instead of button for disabled prev/next …
Browse files Browse the repository at this point in the history
…controls (#4951)

* fix(Pagination): a11y improvements

* Create friendly-boats-serve.md

* fix(Pagination): only add role link to disabled anchors
  • Loading branch information
francinelucca authored Sep 16, 2024
1 parent b74c47f commit c9009de
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-boats-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

fix(Pagination): Use anchor instead of button for disabled prev/next controls
13 changes: 5 additions & 8 deletions packages/react/src/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@ const Page = styled.a`
&[aria-disabled],
&[aria-disabled]:hover {
color: ${get('colors.primer.fg.disabled')}; // check
cursor: default;
background-color: transparent;
border-color: transparent;
font-size: inherit;
font-family: inherit;
padding-top: inherit;
padding-bottom: inherit;
margin: 0 2px;
&:first-child {
margin-right: 6px;
}
}
&[aria-disabled],
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/Pagination/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function buildComponentData(
key = 'page-prev'
content = 'Previous'
if (page.disabled) {
Object.assign(props, {as: 'button', 'aria-disabled': 'true'})
Object.assign(props, {'aria-disabled': 'true', role: 'link'})
} else {
Object.assign(props, {
rel: 'prev',
Expand All @@ -163,7 +163,7 @@ export function buildComponentData(
key = 'page-next'
content = 'Next'
if (page.disabled) {
Object.assign(props, {as: 'button', 'aria-disabled': 'true'})
Object.assign(props, {'aria-disabled': 'true', role: 'link'})
} else {
Object.assign(props, {
rel: 'next',
Expand Down

0 comments on commit c9009de

Please sign in to comment.