Skip to content

[Bug]: <Button> does not correctly apply aria-describedby when used inside <Callout> (React Carbon) #19418

Closed
@grek889

Description

@grek889

Package

@carbon/react

Browser

No response

Package version

1.80.0

React version

18.3.1

Description

When using a custom Button component that wraps Carbon’s Button inside a Callout, an accessibility error is thrown in Storybook:

Error: interactive child node(s) should have an `aria-describedby` property with a value matching the value of `titleId`.

Even though I pass aria-describedby explicitly to the custom Button, the rendered output seems to ignore or overwrite it.

Reproduction/example

https://stackblitz.com/edit/github-1qhjyknb?file=src%2FApp.tsx

Steps to reproduce

  1. Create a wrapper component around Carbon’s and pass aria-describedby as a direct prop (not via ...rest).

  2. Use this custom Button inside a Carbon component that also defines a title and titleId.

  3. Pass the titleId as the value for aria-describedby in the Button:

const titleId = useId();

<Callout title="Alert Title" titleId={titleId}>
  <Button
    aria-describedby={titleId}
    iconDescription="Close alert"
    hasIconOnly
  />
</Callout>

4.Render this component.

  1. Observe the console.

Suggested Severity

None

Application/PAL

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions