feat: fix a11y issues in icon component#663
Conversation
Coverage report for library
Test suite run success1323 tests passing in 37 suites. Report generated by 🧪jest coverage report action from f798fc2 |
Playwright test resultsDetails
|
| styleUrls: ['./cps-icon.component.scss'] | ||
| styleUrls: ['./cps-icon.component.scss'], | ||
| host: { | ||
| '[attr.role]': 'ariaLabel ? "img" : null', |
There was a problem hiding this comment.
@fateeand If I understand everything correctly, cps-icon now treats icons as decorative unless the new ariaLabel input is used. A consumer passing the standard aria-label="Search" attribute will have it removed/ignored by the host binding and the icon becomes aria-hidden="true".
If I'm right, then possible solution: support the native alias too, e.g. @input('aria-label'), and add a test for
There was a problem hiding this comment.
@korel-san I spent quite a bit of time thinking about a better approach. The solution I just pushed handles all supported ways of providing an accessible label to the component: native HTML attributes ([attr.aria-label], aria-label) as well as the ariaLabel input. Any of these can be used, and they now serve as the baseline for determining whether an icon should be treated as decorative or informative. Also updated the doc for ariaLabel input.
If e.g. consumers set role="img" but do not provide an accessible label, the role will be removed, which is a valid outcome. Similarly, if consumers set aria-hidden="false" but also provide an accessible label, aria-hidden will be overridden to true, since having both a visible label and aria-hidden enabled is contradictory.
Overall, the only requirement for consumers is to provide an aria label in any form to determine whether the icon should be treated as informative or decorative.
Fixing accessibility issues in icon component
Validation rules:
Validated using Playwright accessibility tests, Lighthouse tool, and manual checks including keyboard tab navigation and screen reader testing.
Full doc with rules
Checklist
[N/A] Keyboard Navigation
All interactive elements are fully operable via keyboard only, including buttons, inputs, menus, dialogs, sliders, drag-and-drop, tree views, multi-selects, and composite widgets. No traps or dead ends.
[N/A] Focus Management
Focus is visible, logical, moves in predictable order, trapped where necessary (modals/popovers), and restored after closing. Focus is perceivable in all interactive widgets.
Semantics / ARIA
[N/A] Color / Contrast
Screen Reader / Assistive Technology
Responsive & Zoom
[N/A] Error Handling
[N/A] Dynamic Content / Updates
[N/A] Interaction Feedback / States
[N/A] Authentication & Sensitive Actions
[N/A] Predictable & Controllable UI
Release notes: