Skip to content

fix: support accessibilityLabelledBy arrays#1907

Open
sjh9714 wants to merge 1 commit into
callstack:mainfrom
sjh9714:fix-accessibility-labelledby-array-name
Open

fix: support accessibilityLabelledBy arrays#1907
sjh9714 wants to merge 1 commit into
callstack:mainfrom
sjh9714:fix-accessibility-labelledby-array-name

Conversation

@sjh9714
Copy link
Copy Markdown

@sjh9714 sjh9714 commented May 17, 2026

Summary

Fixes accessible name matching when accessibilityLabelledBy is an array.

React Native types allow accessibilityLabelledBy to be string | string[], but
the previous lookup compared nativeID directly with the prop value. That made
getByRole('button', { name }) miss elements labelled by an array value.

This PR keeps the existing string behavior and normalizes the label id prop to
an array before matching label elements.

Fixes #1839

Test plan

  • yarn test src/queries/__tests__/role.test.tsx -t accessibilityLabelledBy
  • yarn test src/queries/__tests__/role.test.tsx
  • yarn typecheck
  • yarn lint
  • yarn test
  • yarn prettier
  • git diff --check

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.

getByRole with name option fails when accessibilityLabelledBy is an array

1 participant