Skip to content

Fix FormControl + SelectPanel accessible name to address SR issues - #7624

Merged
llastflowers merged 4 commits into
mainfrom
llastflowers/14989/SelectPanel-SR-fix
Mar 5, 2026
Merged

Fix FormControl + SelectPanel accessible name to address SR issues#7624
llastflowers merged 4 commits into
mainfrom
llastflowers/14989/SelectPanel-SR-fix

Conversation

@llastflowers

@llastflowersllastflowers commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Addresses https://github.com/github/accessibility-audits/issues/14989

Changelog

Changed

Fixed SR announcement issue for FormControl.Label + SelectPanel where label[for] referenced the SelectPanel’s anchor button, causing the announcement to drop the selected items; we now avoid htmlFor in this case and auto-compose the anchor’s aria-labelledby from the label and selected value.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@llastflowersllastflowers self-assigned this Mar 4, 2026
@llastflowers
llastflowers requested a review from a team as a code ownerMarch 4, 2026 19:08
@changeset-bot

changeset-botBot commented Mar 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 640a24d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

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

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Mar 4, 2026

CopilotAI 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 fixes an accessible-name regression when FormControl.Label is used with SelectPanel, where wiring the label via htmlFor to the SelectPanel’s anchor button caused screen readers to announce only the label (dropping the selected value). The change introduces FormControl→SelectPanel coordination so the anchor’s accessible name is composed from both the label and the selected value.

Changes:

  • Add isReferenced + labelId to FormControl context to control whether FormControl.Label should set htmlFor.
  • Update FormControl.Label to optionally omit htmlFor and to default its own id from context.
  • Update SelectPanel to auto-compose the anchor’s aria-labelledby from the label id + selected value (and render the selected value in an id’d <span>).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

FileDescription
packages/react/src/SelectPanel/SelectPanel.tsxAuto-wires anchor aria-labelledby to include FormControl label + selected value.
packages/react/src/FormControl/_FormControlContext.tsxExtends FormControl context with isReferenced and labelId used for labeling behavior.
packages/react/src/FormControl/FormControlLabel.tsxUses context to set a default id and to suppress htmlFor when not appropriate.
packages/react/src/FormControl/FormControl.tsxDetects SelectPanel input and provides isReferenced/labelId via context.

Comment threadpackages/react/src/FormControl/FormControl.tsx Outdated
Comment threadpackages/react/src/SelectPanel/SelectPanel.tsx
Comment threadpackages/react/src/FormControl/FormControlLabel.tsx
@primer-integration

Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/15139

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed CI  Passed
Passed VRT  Passed
Passed Projects  Passed

All checks passed!

@TylerJDevTylerJDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Fixes the accessible name for FormControl and SelectPanel to improve screen reader compatibility.
@llastflowers

Copy link
Copy Markdown
ContributorAuthor

skipping integration tests as they passed but stopped reporting in CI after I added the changeset

@llastflowers
llastflowers added this pull request to the merge queueMar 5, 2026
Merged via the queue into main with commit f6d4311Mar 5, 2026
56 checks passed
@llastflowers
llastflowers deleted the llastflowers/14989/SelectPanel-SR-fix branch March 5, 2026 00:16
@primerprimerBot mentioned this pull request Mar 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpmintegration-tests: skipped manuallyChanges in this PR do not require an integration test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@llastflowers@TylerJDev