Skip to content

ProgressBar aria-label is still warned out even if we pass aria-hidden #9987

@bertearazvan

Description

@bertearazvan

Provide a general summary of the issue here

ProgressBar emits a console warning requiring aria-label or aria-labelledby even when aria-hidden={true} is passed.

🤔 Expected Behavior?

When aria-hidden={true} is set, no accessibility label warning should be emitted. The element is excluded from the accessibility tree, so a label is neither required nor meaningful.

😯 Current Behavior

useLabel inside useProgressBar unconditionally checks for the presence of label, aria-label, or aria-labelledby and warns if none is found — regardless of whether aria-hidden={true} is also set.

If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility

💁 Possible Solution

In useLabel (or useProgressBar), skip the label warning when aria-hidden={true} is present on the element, since the ARIA spec states that aria-hidden removes the element and its entire subtree from the accessibility tree — making labelling requirements moot.

🔦 Context

In our use case we use it as a visual indication for a step into a stepper. The steps are predefined and the bar is set to some static visual sizes (0, 50%, 100%) for either not started, in progress or completed. In this case, accessiblity-wise it does not provide the value by itself, but rather the step it is part of is the one providing accessibility value. That being said, the bar does not have an accessible value and we pass aria-hidden to it. Given the warning is being returned, we have a workaround but it's not actually correct and it should now return a warning if aria-hidden is passed.

Image

🖥️ Steps to Reproduce

  1. Render <ProgressBar value={50} aria-hidden /> from react-aria-components.
  2. Observe the console warning in development mode: "If you do not provide a visible label, you must specify an aria-label or aria-labelledby attribute for accessibility"
  3. Adding aria-label="" suppresses the warning but is semantically unnecessary since the element is hidden from assistive technology

Version

1.15.1

What browsers are you seeing the problem on?

Other

If other, please specify.

Not browser-specific. Reproducible in any environment where NODE_ENV !== 'production', including Jest/jsdom and all major browsers in development mode (Chrome, Firefox, Safari, Edge).

What operating system are you using?

Windows 11

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions