Skip to content

fix(Combobox): add aria attributes on error#2327

Open
chornonoh-vova wants to merge 1 commit intodevelopfrom
fix/a11y-combobox-error-input-invalid-listbox-describedby
Open

fix(Combobox): add aria attributes on error#2327
chornonoh-vova wants to merge 1 commit intodevelopfrom
fix/a11y-combobox-error-input-invalid-listbox-describedby

Conversation

@chornonoh-vova
Copy link
Copy Markdown
Contributor

Summary

  • add aria-invalid to internal <input /> when there's an error
  • add aria-describedby to the internal <Listbox />

Together, these 2 attributes form correct representation of the error
state to the screen reader.

When they were missing previously, VoiceOver was not announcing an error
message (even though NVDA did).

- add `aria-invalid` to internal `<input />` when there's an error
- add `aria-describedby` to the internal `<Listbox />`

Together, these 2 attributes form correct representation of the error
state to the screen reader.
@chornonoh-vova chornonoh-vova requested a review from a team as a code owner April 17, 2026 14:36
Copilot AI review requested due to automatic review settings April 17, 2026 14:36
Copy link
Copy Markdown
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

Updates the Combobox component’s accessibility semantics so assistive technologies can correctly announce error state and associated messaging (notably improving VoiceOver behavior).

Changes:

  • Add aria-invalid to the internal combobox <input> when error is present.
  • Apply the computed aria-describedby value to the internal <Listbox /> as well as the input.
  • Add tests covering aria-invalid, listbox aria-describedby, and an additional axe check for error state.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react/src/components/Combobox/Combobox.tsx Adds aria-invalid handling and shares computed aria-describedby with the listbox.
packages/react/src/components/Combobox/Combobox.test.tsx Adds unit/behavior tests for the new ARIA attributes and an axe test for error state.
Comments suppressed due to low confidence (1)

packages/react/src/components/Combobox/Combobox.tsx:746

  • aria-invalid is set before {...inputProps}, but inputProps is built from the remaining props (which can include a consumer-provided aria-invalid since BaseComboboxProps extends InputHTMLAttributes). Because the spread comes after, a passed aria-invalid would override the error-driven value, potentially leaving the input not marked invalid even when error is rendered. Consider ensuring the component-owned aria-invalid wins (e.g., move the spread earlier or explicitly strip/override aria-invalid when error is present).
            aria-invalid={error ? true : undefined}
            aria-autocomplete={!isAutoComplete ? 'none' : 'list'}
            aria-controls={`${id}-listbox`}
            aria-expanded={open}
            aria-haspopup="listbox"
            aria-activedescendant={
              open && activeDescendant ? activeDescendant.element.id : undefined
            }
            {...inputProps}

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

@aws-amplify-us-east-1
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2327.d15792l1n26ww3.amplifyapp.com

Copy link
Copy Markdown
Contributor

@Bracciata Bracciata left a comment

Choose a reason for hiding this comment

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

This looks good to me! Claude brought up a concern of consumers overriding props, however, I don't think that is worth us considering.

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.

3 participants