Repository navigation
Fix disabled pagination controls accessibility - #2867
Merged
Merged
Conversation
Collaborator
Author
|
No actionable findings in PR #2867 ( Reviewed Source review only; no runtime or accessibility tests run. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The scenario
When a user renders
<flux:pagination :paginator="$paginator" />on the first or last page, axe reports a seriousaria-prohibited-attrviolation on the unavailable Previous/Next control.The problem
When there's no previous/next page, the control is rendered as a plain
divwith anaria-label. Adivhas no role, and ARIA doesn't allow naming elements without a role, so the label is ignored by screen readers and flagged by axe:Because of this, the disabled control is not exposed at all, while the enabled one is a
button. Screen reader users on the first page only hear "Next" and have no way of telling that "Previous" exists but is unavailable.The disabled Next control was also missing
aria-disabled, so even with a role it wouldn't be announced as disabled.The simple layout (used for
PaginatorandCursorPaginator) has the same problem in a different shape: its disabled controls have no label at all, and its enabled buttons have no accessible name either, which axe reports asbutton-name(critical).The solution
Render the unavailable controls as native disabled buttons, keeping the same classes and icons:
This matches the enabled controls, so screen readers now announce both as buttons, with the unavailable one marked as disabled. A native
disabledbutton is also skipped in the tab order and can't be clicked, just like thedivbefore, and Tailwind's preflight resets the default button styles, so it looks exactly the same.In the simple layout, the disabled controls get the same treatment and the enabled buttons get the same
aria-labels as in the default layout.Accessibility tree on the first page, before:
After:
Fixes #2771