-
Notifications
You must be signed in to change notification settings - Fork 129
Give inputs unique ids so that SR doesn't skip Label announcement #3874
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
Give inputs unique ids so that SR doesn't skip Label announcement #3874
Conversation
…when initial selection changes
🦋 Changeset detectedLatest commit: 7d2e5c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Assign unique IDs to inputs for improved accessibility.
… github.com:primer/view_components into llastflowers/14774/region-label-sr-announcement-fix
… github.com:primer/view_components into llastflowers/14774/region-label-sr-announcement-fix
There was a problem hiding this comment.
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 the MultiInput form control so that screen readers consistently announce its label, and wires that behavior into the axe/preview tooling and metadata.
Changes:
- Ensure form labels have stable, unique
idattributes derived from the inputbase_id, and wire multi-input children to reference those labels viaaria-labelledby. - Update the
MultiInputDSL to give each constituent input a uniqueid, associate it with the shared label, and keep hidden inputs disabled while still present in the DOM. - Extend accessibility configuration (axe skip rules and static preview/info architecture JSON) for the
MultiInputvisually-hidden-label scenario and add a changeset for@primer/view-components.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
static/previews.json |
Updates the multi_input/visually_hide_label preview’s skip_rules.wont_fix to include the label-title-only rule so CI reflects the expected a11y exception. |
static/info_arch.json |
Mirrors the preview configuration by adding label-title-only to wont_fix for the multi_input/visually_hide_label preview entry in the information architecture metadata. |
lib/primer/accessibility.rb |
Adds a per-component wont_fix rule for Primer::Alpha::MultiInput’s visually_hide_label scenario and normalizes scenario_name (string vs symbol) before looking up scenario-specific axe rules. |
app/lib/primer/forms/form_control.html.erb |
Ensures every label rendered by the forms FormControl wrapper has a deterministic id (label-<base_id>) while still respecting any explicitly provided id. |
app/lib/primer/forms/dsl/multi_input.rb |
Adjusts decorate_options so each child input in a multi-input gets a unique id and an aria-labelledby pointing at the shared label, and keeps hidden inputs disabled to avoid server submission. |
.changeset/hip-flies-pretend.md |
Records a patch release for @primer/view-components summarizing the new unique-ID behavior for multi-input labels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What are you trying to accomplish?
Integration
N/A
List the issues that this change affects.
Addresses https://github.com/github/accessibility-audits/issues/14774
Risk Assessment
What approach did you choose and why?
The label was not being announced when the initial selection was changed because the inputs did not have unique IDs. Now that they have unique ids, the label will always be announced regardless of selection state.
Anything you want to highlight for special attention from reviewers?
N/A
Accessibility
Fix for a11y audit remediation issue
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.