feat: fix a11y issues in switch component#656
Merged
Conversation
Contributor
Coverage report for library
Test suite run success1212 tests passing in 34 suites. Report generated by 🧪jest coverage report action from a832517 |
Contributor
Playwright test resultsDetails
|
lukasmatta
reviewed
Jun 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the accessibility of CpsSwitchComponent in the UI kit by adding proper ARIA semantics/labels, improving focus visibility and target sizing, and re-enabling automated a11y coverage for the Switch page in Playwright.
Changes:
- Add
ariaLabelsupport +role="switch"and improve focus handling for the switch input. - Update switch styling for better focus ring, sizing (rem units), and disabled-state contrast.
- Add/extend unit tests and re-enable Switch in Playwright accessibility coverage; update composition docs/examples.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.ts | Adds ariaLabel, logs missing labeling for a11y, and switches focus implementation to ViewChild. |
| projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.html | Adds role="switch", binds aria-label, and marks decorative slider as aria-hidden. |
| projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.scss | Updates sizing to rem, improves focus ring styling, and adjusts disabled colors for contrast. |
| projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.spec.ts | Extends tests to cover new a11y attributes and improves some assertions. |
| projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.ts | Updates focus implementation to use ViewChild instead of querying the host element. |
| projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.html | Adds a template ref for ViewChild focus support. |
| projects/composition/src/app/pages/switch-page/switch-page.component.html | Updates example to provide an ariaLabel for an unlabeled switch instance. |
| projects/composition/src/app/pages/switch-page/switch-page.component.scss | Minor layout tweaks using rem-based spacing. |
| projects/composition/src/app/api-data/cps-switch.json | Documents the new ariaLabel prop and updates wording for existing props. |
| playwright/cps-accessibility.spec.ts | Re-enables the Switch route for automated axe-core validation. |
lukasmatta
approved these changes
Jun 10, 2026
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.
Fixing accessibility issues in switch 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
Playwright axe-core validation results:
State before:
State after:
Checklist
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.
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
Color / Contrast
Screen Reader / Assistive Technology
Responsive & Zoom
[N/A] Error Handling
[N/A] Dynamic Content / Updates
Interaction Feedback / States
[N/A] Authentication & Sensitive Actions
Predictable & Controllable UI
Release notes: