Skip to content

feat: fix a11y issues in switch component#656

Merged
fateeand merged 6 commits into
masterfrom
595-fix-a11y-issues-in-switch-component
Jun 10, 2026
Merged

feat: fix a11y issues in switch component#656
fateeand merged 6 commits into
masterfrom
595-fix-a11y-issues-in-switch-component

Conversation

@fateeand

@fateeand fateeand commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

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:

Component aria-roles color-contrast label tabindex target-size
Switch - - -

State after:

Component aria-roles color-contrast label tabindex target-size
Switch

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

    • Semantic HTML is used correctly.
    • ARIA roles, states, and properties are applied only when needed.
    • All form fields, tables, and widgets (including autocomplete, tree selects, tree tables, drag-and-drop, sliders, and multi-selects) are properly labeled and accessible.
  • Color / Contrast

    • Text and interactive elements meet contrast requirements (≥4.5:1 normal text, ≥3:1 large text).
    • Focus and selection indicators are visually perceivable.
    • Color is not the only indicator of state.
  • Screen Reader / Assistive Technology

    • All content, labels, and dynamic updates are perceivable via screen readers.
    • Live regions announce status messages, alerts, modals, notifications, and dynamic changes.
    • Interactive widgets provide proper announcements of selection and updates.
  • Responsive & Zoom

    • Components function correctly and remain readable at all viewport sizes and up to 200% zoom, including mobile and touch devices.
    • Prefer em/rem units over px where scaling is required.
  • [N/A] Error Handling

    • Errors are clearly identified visually and programmatically.
    • Form inputs use aria-describedby or aria-invalid for inline messages.
    • Instructions and suggestions are accessible.
  • [N/A] Dynamic Content / Updates

    • Status updates, alerts, notifications, and modals use live regions.
    • Updates do not disrupt focus or user control unexpectedly.
  • Interaction Feedback / States

    • All interactive states (hover, focus, active, disabled, drag-and-drop, reordering, multi-select) are visually perceivable.
  • [N/A] Authentication & Sensitive Actions

    • Inputs and actions involving sensitive data provide accessible instructions, feedback, and error messages.
  • Predictable & Controllable UI

    • Components behave consistently and predictably.
    • Popups, modals, autocomplete suggestions, drag-and-drop, and dynamic content allow user control.

Release notes:

  • Fix a11y issues in switch component

@fateeand fateeand linked an issue Jun 5, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Coverage report for library

St.
Category Percentage Covered / Total
🔴 Statements 48.13% 3544/7364
🔴 Branches 43.56% 1590/3650
🔴 Functions 47.33% 666/1407
🔴 Lines 48.67% 3302/6785

Test suite run success

1212 tests passing in 34 suites.

Report generated by 🧪jest coverage report action from a832517

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Playwright test results

passed  90 passed

Details

stats  90 tests across 4 suites
duration  3 minutes
commit  a832517
info  For details, download the Playwright report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ariaLabel support + 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.

@fateeand fateeand merged commit 39ced42 into master Jun 10, 2026
11 checks passed
@fateeand fateeand deleted the 595-fix-a11y-issues-in-switch-component branch June 10, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix a11y issues in switch component

3 participants