Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] <pf-switch /> - Switch lacks a static accessible label #2754

Open
adamjohnson opened this issue Apr 23, 2024 · 1 comment
Open

[bug] <pf-switch /> - Switch lacks a static accessible label #2754

adamjohnson opened this issue Apr 23, 2024 · 1 comment
Labels
accessibility Improve accessibility bug priority: medium Severity level: 2

Comments

@adamjohnson
Copy link
Collaborator

Description of the issue

<pf-switch /> lacks an accessible static label. The current label uses the state of the switch as the label.

Impacted component(s)

  • <pf-switch />

Steps to reproduce

Basic Demo

  1. Go to the <pf-switch /> "Basic" demo.
  2. When clicking the switch, the message changes from "Message when on" to "Message when off". These messages incorrectly act as the label for the switch.

Without Label Demo

  1. Go to the "Without Label" demo.
  2. This demo lacks an accessible label and accessible states for its controls.

Other demos

Similarly, the "Checked with label" and "Disabled" follow these trends and need fixed.

Expected behavior

All <pf-switch /> elements should include an accessible label for the control.

  1. They should also have an aria-describedby attribute that targets the controls toggled state options.
  2. If a <label> isn't used, the switch needs an accessible-label property/attribute.

Proposed fixes:

<label for="with-label">Switch B</label>
<pf-switch id="with-label" aria-describedby="b" checked>
  <div id="b">
    <span data-state="on">Message when on</span>
    <span data-state="off" hidden>Message when off</span>
  </div>
</pf-switch>
<pf-switch aria-describedby="a" accessible-label="Switch A" checked>
  <div id="a">
    <span data-state="on">Message when on</span>
    <span data-state="off" hidden>Message when off</span>
  </div>
</pf-switch>

Related to RedHat-UX/red-hat-design-system#1513 (comment).

@adamjohnson adamjohnson added accessibility Improve accessibility priority: medium Severity level: 2 bug labels Apr 23, 2024
@bennypowers
Copy link
Member

bennypowers commented Apr 23, 2024

Since switch is a FACE, we can just associate it with a label, and we'll be good to go.

We already do this, just that when the state changes, we check for specially marked children of that label and hide or show then depending on their attributes

Fixing this issue should simplify the implementation of switch as well, because we could simply provide a pair of slots (with complimentary attributes) for the descriptions

This is all dependent on the upstream design

<label for=a>label!</label>
<pf-switch id=a>
  <span slot="off">Off!</span>
  <span slot="on">On!</span>
</pf-switch>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Improve accessibility bug priority: medium Severity level: 2
Projects
None yet
Development

No branches or pull requests

2 participants