Skip to content
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

fix(Pagination): Use anchor instead of button for disabled prev/next controls #4951

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Comment on lines +79 to +83
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do this to enforce no visual regressions when changing from button to anchor to account for the 2px border all buttons have. Couldn't find a mapping in the theme spaces but happy to do this differently if there's a better alternative!

}

&[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
Loading