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

fix(Switch): updated a11y by removing dynamic labeling #10646

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

thatblindgeye
Copy link
Contributor

@thatblindgeye thatblindgeye commented Jun 24, 2024

What: Closes #10645

Codemod issue: patternfly/pf-codemods#672

Additional issues:

@thatblindgeye thatblindgeye requested review from a team, tlabaj and kmcfaul and removed request for a team June 24, 2024 18:52
@thatblindgeye thatblindgeye linked an issue Jun 24, 2024 that may be closed by this pull request
@thatblindgeye thatblindgeye requested review from a team and jessiehuff and removed request for a team June 24, 2024 18:55
@patternfly-build
Copy link
Contributor

patternfly-build commented Jun 24, 2024

labelOff?: React.ReactNode;
/** Adds an accessible name to the switch when the label prop is not passed, and must describe the isChecked="true" state. */
'aria-label'?: string;
/** Adds an accessible name to the switch via a list of referenced id's. The computed accessible name must describe the isChecked="true" state. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily a suggestion, but I wonder if someone will think it needs to be a list of id's (versus being able to use a single id) the way it's worded currently?

Suggested change
/** Adds an accessible name to the switch via a list of referenced id's. The computed accessible name must describe the isChecked="true" state. */
/** Adds an accessible name to the switch via referenced id(s). The computed accessible name must describe the isChecked="true" state. */

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM! One question - if there is no label, aria-label, and aria-labelledby, we have a console.error, but we still apply aria-labelledby="[switch-id]-label", which wouldn't work out of the box since no label was passed. Just want to make sure that's preferred over not applying aria-labelledby?

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

VO and keyboard look good!

I think it may be worth even just a sentence somewhere in the Switch docs to ensure that the consumer knows that they need to consider a11y and wire things up correctly to be a11y compliant. Maybe directing them to the a11y docs or just calling out the most common scenario - something like that?

@@ -30,8 +32,6 @@ export interface SwitchProps
isDisabled?: boolean;
/** A callback for when the switch selection changes. (event, isChecked) => {} */
onChange?: (event: React.FormEvent<HTMLInputElement>, checked: boolean) => void;
/** Adds accessible text to the switch, and should describe the isChecked="true" state. When label is defined, aria-label should be set to the text string that is visible when isChecked is true. */
'aria-label'?: string;
/** Flag to reverse the layout of toggle and label (toggle on right). */
Copy link
Contributor

Choose a reason for hiding this comment

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

can you update the text while in there. Or we can open a follow up issue. For RTL purposes it should say "end" rather than right". I would advocate for actually changing the name to better align with other components. Maybe togglePosition. we can introduce a new prop post v5. i can add new issue for that.

// eslint-disable-next-line no-console
console.error('Switch: Switch requires either a label or an aria-label to be specified');
console.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would as unit test for this. That can be follow up. If we want to get this in.

@tlabaj tlabaj merged commit 730ac69 into patternfly:v6 Jul 3, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug - Switch - accessibility issues due to dynamic labeling
5 participants