🎨 Palette: Standardize pagination icon-only buttons for accessibility - #1998
🎨 Palette: Standardize pagination icon-only buttons for accessibility#1998damacus wants to merge 1 commit into
Conversation
- Moved `sr-only` span text to `aria-label` attributes on the parent elements for active links. - Hidden decorative chevron icons using `aria_hidden: 'true'`. - Enhanced disabled state spans by adding `role: 'button'` and `aria-disabled: 'true'` to ensure screen readers correctly interpret them as disabled controls rather than ignoring the `aria-label`. Co-authored-by: damacus <40786+damacus@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| data: { turbo_frame: 'admin-users-frame' }, | ||
| "aria-label": t('admin.users.pagination.previous') | ||
| ) do | ||
| span(class: 'sr-only') { t('admin.users.pagination.previous') } | ||
| plain '‹' | ||
| span(aria_hidden: 'true') { plain '‹' } |
There was a problem hiding this comment.
🔍 Pagination tests still require removed markup
Existing component specs still require .sr-only nodes. The mandatory test gate fails after aria-label replaces them.
Was this helpful? React with 👍 or 👎 to provide feedback.
| ## 2024-03-24 - Phlex Pagination Accessibility Refactoring | ||
| **Learning:** When refactoring icon-only buttons for accessibility in Phlex components, be cautious of Phlex's block rendering semantics. Returning a string literal inside a Phlex block (e.g., `span { '‹' }`) does not output the text; you must explicitly use the `plain` helper (e.g., `span { plain '‹' }`). Also, when applying `aria-label` to disabled placeholder elements (like a generic non-interactive `span`), remember to include `role="button"` and `aria-disabled="true"` so screen readers correctly identify the element as a disabled interactive control instead of ignoring the `aria-label`. | ||
| **Action:** Always use `plain` for text nodes in Phlex blocks and pair `aria-label` with an appropriate interactive role (`role="button"`) and state (`aria-disabled="true"`) when mocking disabled buttons with plain `span` elements. |
💡 What:
Standardized the accessibility markup for the "Previous" and "Next" pagination icon-only buttons in
app/components/admin/users/pagination.rb. Removed visually hiddensr-onlyinner text and replaced it with cleanaria-labelattributes on the parent elements. Addedrole="button"andaria-disabled="true"to the disabled placeholder elements.🎯 Why:
This is a modern accessibility best practice for icon-only interactive elements. It prevents screen readers from redundantly announcing the visual character (like "Previous less-than") and ensures that disabled states are correctly announced as inactive controls rather than completely skipped by virtual cursors.
📸 Before/After:
(Visual changes remain functionally identical; chevrons are still displayed but are now
aria-hidden.)♿ Accessibility:
Improved structural semantics for assistive technologies reading pagination controls, standardizing them across both their active (
Link) and disabled (span) states.PR created automatically by Jules for task 10201013275391994045 started by @damacus