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

aria-labelledby referencing a combobox does not resolve accessible name correctly #1070

Open
elianarlivingston opened this issue Dec 27, 2024 · 0 comments

Comments

@elianarlivingston
Copy link

elianarlivingston commented Dec 27, 2024

Hi,

I’m encountering an issue with aria-labelledby in Testing Library when it references the id of an element with role="combobox". The accessible name is not being resolved as expected in this case.

Code Example:

it('Example', () => {
  render(
    <div>
      <button
        aria-labelledby="label value"
        id="trigger"
        role="combobox"
      >
        <span id="label">Label</span>
        <span id="value">Value</span>
      </button>
      <input aria-labelledby="trigger" />
    </div>,
  );

  const input = screen.getByRole('textbox');
  expect(computeAccessibleName(input)).toBe('Label Value');
});

Expected behavior:

The input's accessible name should be Label Value because aria-labelledby references an element with id="trigger", which contains accessible children with id="label" and id="value".

Observed behavior:

The accessible name is not resolved correctly, causing the test to fail.

Additional context:

It seems that this issue occurs because role="combobox" affects how aria-labelledby resolves the accessible name. According to the ARIA specification, a combobox should be associated with additional controls, such as a listbox or a textbox. However, this scenario should still be considered valid.

Question:

Is this behavior expected given the current implementation, or is it a bug in how aria-labelledby resolves when referencing a combobox?

Versions:

React Testing Library: <14.3.1>
DOM Testing Library: <9.3.4>
Dom Accessibility Api: <0.5.16>

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

No branches or pull requests

1 participant