-
Notifications
You must be signed in to change notification settings - Fork 538
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
francinelucca
merged 6 commits into
main
from
francinelucca/3395-prcpagination-best-practice-make-disabled-previousnext-control-non-focusable
Sep 16, 2024
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b987ad
fix(Pagination): a11y improvements
francinelucca 0832e2a
Create friendly-boats-serve.md
francinelucca 06e46ec
Merge branch 'main' into francinelucca/3395-prcpagination-best-practi…
francinelucca 84ce8ca
Merge branch 'main' into francinelucca/3395-prcpagination-best-practi…
francinelucca 311f98d
Merge branch 'main' of github.com:primer/react into francinelucca/339…
francinelucca cca5a45
fix(Pagination): only add role link to disabled anchors
francinelucca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,13 +148,14 @@ 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'}) | ||
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. We can add |
||
} else { | ||
Object.assign(props, { | ||
rel: 'prev', | ||
href: hrefBuilder(page.num), | ||
'aria-label': 'Previous Page', | ||
onClick, | ||
role: 'link', | ||
}) | ||
} | ||
break | ||
|
@@ -163,13 +164,14 @@ 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'}) | ||
} else { | ||
Object.assign(props, { | ||
rel: 'next', | ||
href: hrefBuilder(page.num), | ||
'aria-label': 'Next Page', | ||
onClick, | ||
role: 'link', | ||
}) | ||
} | ||
break | ||
|
@@ -185,6 +187,7 @@ export function buildComponentData( | |
'aria-label': `Page ${page.num}${page.precedesBreak ? '...' : ''}`, | ||
onClick, | ||
'aria-current': page.selected ? 'page' : undefined, | ||
role: 'link', | ||
}) | ||
break | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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!