Skip to content

Conversation

@francinelucca
Copy link
Member

@francinelucca francinelucca commented Jan 22, 2026

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

Adds aria-label prop to preview ToggleSwich stories

Screenshots

Before:
(no aria name on button)
chrome browser showing sample toggleswitch with no aria-label in the button

After:
(aria name on button)
chrome browser showing sample toggleswitch with 'toggle switch' as the aria-label

Integration

N/A

List the issues that this change affects.

Closes https://github.com/github/accessibility-audits/issues/14754

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

Confirmed the aria-label can be provided through system props, so just added aria-labels to preview stories to remediate the a11y issue.

Anything you want to highlight for special attention from reviewers?

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@francinelucca francinelucca requested a review from a team as a code owner January 22, 2026 02:37
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

⚠️ No Changeset found

Latest commit: 3c4cb8e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Add default aria-label to ToggleSwitch component for accessibility.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a default accessible name to the Primer::Alpha::ToggleSwitch button so it no longer renders without an ARIA name.

Changes:

  • Introduces a default accessible name ("toggle switch") when no aria-label is provided.
  • Adds aria-label into the merged button ARIA attributes alongside aria-pressed.
Comments suppressed due to low confidence (1)

app/components/primer/alpha/toggle_switch.rb:82

  • This change introduces new accessibility behavior (default aria-label + preserving any custom label). There are existing component tests for ToggleSwitch, but none currently assert the rendered button has an accessible name; adding/adjusting a test to cover the default label and that a custom aria-label is not overwritten would prevent regressions.
          aria: merge_aria(
            @system_arguments,
            aria: { pressed: on?, label: @accessible_name}
          )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Jan 22, 2026

@francinelucca I've opened a new pull request, #3870, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: francinelucca <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@francinelucca
Copy link
Member Author

@copilot open a new pull request against the main branch to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Jan 22, 2026

@francinelucca I've opened a new pull request, #3871, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Member

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

I think you were planning on adding changes, so approving in advance!

@francinelucca francinelucca changed the title fix(ToggleSwitch): add default aria-label chore(ToggleSwitch): add aria-label to preview stories Jan 28, 2026
@francinelucca francinelucca added skip changeset Pull requests that don't change the library output and removed patch release labels Jan 28, 2026
@francinelucca francinelucca added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit a0d5227 Jan 28, 2026
37 of 38 checks passed
@francinelucca francinelucca deleted the fix/add-default-aria-label-to-toggle-switch branch January 28, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Pull requests that don't change the library output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants