Skip to content
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

[a11y]: Dropdown aria-label prop isn't applied to the correct element #17558

Open
2 tasks done
RachelGHogan opened this issue Sep 23, 2024 · 1 comment · May be fixed by #17588
Open
2 tasks done

[a11y]: Dropdown aria-label prop isn't applied to the correct element #17558

RachelGHogan opened this issue Sep 23, 2024 · 1 comment · May be fixed by #17588
Assignees

Comments

@RachelGHogan
Copy link

RachelGHogan commented Sep 23, 2024

Package

@carbon/react

Browser

No response

Operating System

MacOS

Package version

1.66.0

React version

No response

Automated testing tool and ruleset

IBM Accessibility Scanner Chrome Extension v3.1.75.9999

Assistive technology

No response

Description

When titleText isn't populated/isn't passed as an argument, the dropdown button still has an aria-labelledby field that points to an id not assigned to anything, which causes an accessibility violation.

image

However, if you try to assign aria-label or aria-labelledby yourself, it is applied to the div wrapping the dropdown button instead of the button itself, which causes an accessibility violation.

image

WCAG 2.1 Violation

ARIA specification - States and Properties, ACT rules - ARIA state or property is permitted, ACT rule - Element marked as decorative is not exposed, SC 4.1.2 - Name, Role, Value

Reproduction/example

aria-label applied to div: https://stackblitz.com/edit/github-ba7pgw?file=src%2FApp.jsx aria-labelledby pointing to nothing: https://stackblitz.com/edit/github-ba7pgw-4pybwu?file=src%2FApp.jsx

Steps to reproduce

These issues can be observed in stackblitz. Visit the above links, open the preview window in a new tab, and scan using the accessibility scanner, or:

To Reproduce an aria-label with an ID Not Pointing to Anything:

  1. Visit the Dropdown Storybook
  2. Remove the default title in Storybook
  3. Scan using the accessibility scanner

To Reproduce aria-label/aria-labelledby applied to the div:

  1. Visit the Dropdown Storybook
  2. Add a value to the aria-label field (this should already be set up if using the link above)
  3. Scan using the accessibility scanner

Suggested Severity

None

Code of Conduct

@tay1orjones
Copy link
Member

Thanks for opening this! The issue relates to the downshift functionality specifically called out here:

aria-label: By default the toggle element will add an aria-labelledby that refers to the rendered with getLabelProps. However, if you provide aria-label to give a more specific label that describes the options available, then aria-labelledby will not be provided and screen readers can use your aria-label instead

I think this results in just two changes that need to be made.

  • aria-label on the Listbox is a very old change and should be removed.
  • The existing aria-label prop should instead be passed into getToggleButtonProps() so it works properly as above

@tay1orjones tay1orjones changed the title [a11y]: Dropdown labeling issue [a11y]: Dropdown aria-label prop isn't applied to the correct element Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗 In Progress
Development

Successfully merging a pull request may close this issue.

3 participants