Skip to content

Commit

Permalink
Use button instead of span for disabled prev/next controls (#3277)
Browse files Browse the repository at this point in the history
* Use button instead of span for disabled prev/next controls

* Create kind-scissors-type.md

---------

Co-authored-by: Cole Bemis <colebemis@github.com>
  • Loading branch information
adrianababakanian and colebemis authored May 16, 2023
1 parent b38d2fe commit 0ac31da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-scissors-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

`Pagination`: Use `<button>` instead of `<span>` for disabled prev/next controls to improve accessibility
12 changes: 12 additions & 0 deletions src/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ const Page = styled.a`
border-color: transparent;
}
&[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;
}
&[aria-disabled],
&[aria-disabled]:hover,
&[role='presentation'],
Expand Down
4 changes: 2 additions & 2 deletions 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: 'span', 'aria-disabled': 'true'})
Object.assign(props, {as: 'button', 'aria-disabled': 'true'})
} 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: 'span', 'aria-disabled': 'true'})
Object.assign(props, {as: 'button', 'aria-disabled': 'true'})
} else {
Object.assign(props, {
rel: 'next',
Expand Down

0 comments on commit 0ac31da

Please sign in to comment.