Skip to content

fix(combobox): set aria-controls on the combobox element while open - #3289

Merged
interactivellama merged 2 commits into
masterfrom
fix/combobox-aria-controls
Nov 11, 2026
Merged

interactivellama merged 2 commits into
masterfrom
fix/combobox-aria-controls

Conversation

@interactivellama

@interactivellama interactivellama commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes W-24839159

Additional description

Symptom: with the Combobox menu open, axe reports aria-required-attr: the element with role="combobox" has aria-expanded="true" but no aria-controls. Reproduces on master (11.0.0-alpha.10) and on 0.10.65.

Root cause: the markup put role="combobox" on the .slds-combobox wrapper and role="textbox" on the input (the ARIA 1.1 pattern). aria-controls was only set on the input, which isn't the element axe checks for the combobox's required attributes. This applies to all six render paths: base, inline-listbox single and multiple, readonly single and multiple, and popover. The story snapshots didn't catch it because axe exempts aria-expanded="false" and the stories render closed.

Fix: two commits.

  1. fix(combobox): set aria-controls on the combobox element while open. Sets aria-controls on the role="combobox" element while the popup is rendered: ${id}-listbox for the listbox variants, and ${popoverId}-popover for popover (follows an id set through popover props).
  2. fix(combobox)!: put the combobox role and state on the input (ARIA 1.2). Breaking. Follows the ARIA 1.2 combobox pattern and the SLDS blueprint:
    • role="combobox", aria-expanded, aria-haspopup and aria-controls move from the .slds-combobox wrapper to the input (.slds-combobox__input), which was role="textbox". The wrapper has no role and no aria-owns.
    • aria-autocomplete is only set on the autocomplete variants (base, inline-listbox). Readonly and popover no longer set it.
    • aria-controls is set and aria-expanded is true only while the popup is rendered. The listbox renders only while open and enabled, and that check now honors the deprecated singleInputDisabled as well as disabled. Before, <Combobox singleInputDisabled isOpen /> pointed aria-controls at a listbox that wasn't in the DOM. getDialog uses the same check, so the two can't drift apart.
    • All six input call sites get these attributes from one helper, getComboboxAriaProps(popup, popupId). aria-expanded is derived from whether there's a popup id.

Migration: queries such as getByRole('combobox') now return the input, not the wrapper. Selectors or tests that target .slds-combobox[role="combobox"], role="textbox" on the input, or the wrapper's aria-expanded/aria-owns need updating. Both CHANGELOG.md entries (Changed/BREAKING and Fixed) are updated.

Snapshots: story snapshots change: the role and state attributes move from the wrapper to the input in every combobox story, and readonly/popover lose aria-autocomplete.

Tests: 87 combobox tests pass. New cases cover open and closed/disabled per variant, the custom popover id, the wrapper having no role or aria-owns, and singleInputDisabled on base and readonly. The open-state and singleInputDisabled cases fail without the fix.

TinyNod (advisory): status findings, 3 items, all triaged as false positives: a MOCK-labelled SQL injection finding on changelog prose (CHANGELOG.md:99), bundle size on a test file, and an unspecified naming-convention note on a changelog line that matches its neighbours.

The 0.10.x backport is a separate PR.


CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

  • npm run lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
  • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

Niznikr
Niznikr previously approved these changes Nov 10, 2026
The SLDS markup puts role="combobox" on the .slds-combobox wrapper and
role="textbox" on the input, but aria-controls was only set on the input.
An expanded role="combobox" without aria-controls fails axe
aria-required-attr (W-24839159).

Set aria-controls on the wrapper in all six render paths: the listbox id
for base, inline-listbox and readonly, and the dialog id (following any
id set through popover props) for variant="popover". It is set only
while the target is rendered, and the input uses the same value.
The `.slds-combobox` wrapper had role="combobox" with aria-expanded,
aria-haspopup, aria-controls and aria-owns (the ARIA 1.1 pattern), and
the input was role="textbox". The SLDS blueprint and ARIA 1.2 put
role="combobox", aria-expanded, aria-haspopup and aria-controls on the
focusable input, with the wrapper presentational.

Move them to the input in all six render paths and drop aria-owns.
aria-expanded follows the rendered listbox, so it is false while
disabled. aria-autocomplete="list" stays only on the autocomplete
variants (base, inline-listbox); readonly and popover take no typed
input.

axe reports no aria-required-attr violation in any variant, open or
closed.

BREAKING CHANGE: role="combobox" and its aria-expanded, aria-haspopup
and aria-controls are on the input, not the .slds-combobox wrapper, and
the wrapper no longer sets aria-owns. Queries such as
getByRole('combobox') now return the input.
@interactivellama
interactivellama merged commit 7b47a04 into master Nov 11, 2026
11 checks passed
@interactivellama
interactivellama deleted the fix/combobox-aria-controls branch November 11, 2026 19:27
@interactivellama
interactivellama restored the fix/combobox-aria-controls branch November 11, 2026 19:27
interactivellama added a commit that referenced this pull request Nov 20, 2026
Add axe-core and a shared `expectNoAxeViolations()` helper for the
browser project, where the real SLDS stylesheet is loaded. Run it on the
open or expanded state of Combobox (every variant), MenuDropdown,
Popover, Tooltip, DatePicker, Modal, Accordion, ExpandableSection, Tree
(expanded branches) and ColorPicker.

Closed, axe can't see the popup and exempts `aria-expanded="false"` from
`aria-controls`, and story snapshots render closed, which is how the
Combobox `aria-controls` bug (#3289) shipped. Removing `aria-controls`
from Combobox fails all six open-state Combobox tests.

Two rules are disabled for one render each, with the reason in the test:
- Tree, `label-content-name-mismatch`: axe counts an expanded branch's
  child group as its visible text, so flags the branch `aria-label` that
  keeps the children out of its name. The test asserts the names.
- DatePicker, `target-size`: the calendar button is the SLDS
  `slds-input__icon` blueprint, sized at 0.875rem by SLDS. The calendar
  itself is checked with every rule on.
interactivellama added a commit that referenced this pull request Nov 20, 2026
Add axe-core and a shared `expectNoAxeViolations()` helper for the
browser project, where the real SLDS stylesheet is loaded. Run it on the
open or expanded state of Combobox (every variant), MenuDropdown,
Popover, Tooltip, DatePicker, Modal, Accordion, ExpandableSection, Tree
(expanded branches) and ColorPicker.

Closed, axe can't see the popup and exempts `aria-expanded="false"` from
`aria-controls`, and story snapshots render closed, which is how the
Combobox `aria-controls` bug (#3289) shipped. Removing `aria-controls`
from Combobox fails all six open-state Combobox tests.

Two rules are disabled for one render each, with the reason in the test:
- Tree, `label-content-name-mismatch`: axe counts an expanded branch's
  child group as its visible text, so flags the branch `aria-label` that
  keeps the children out of its name. The test asserts the names.
- DatePicker, `target-size`: the calendar button is the SLDS
  `slds-input__icon` blueprint, sized at 0.875rem by SLDS. The calendar
  itself is checked with every rule on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants