Skip to content

byRole queries don't find element that don't have an explicitly set accessibilityRole prop #1130

Description

@AugustinLF

Describe the bug

react-native built-in elements are not queriable with byRole queries if you don't set the accessibilityRole prop.

Expected behaviour

byRole queries should be able to match some elements without accessibilityRole.

We however need to be conscious of what roles should be used to match what elements. My suggestion is checking each element with a voice-over and see what matches:

  • should <Pressable /> be button by default?
  • <TextInput /> will read Input on ios voiceover, but that is not an AccessibilityRole as exported by react-native.

We might need to think about types. The point raised in #1127 (comment) that suggests using TextMatch for the role will make it harder to discover those cases.

Steps to Reproduce

    Unable to find an element with accessibilityRole: image

      140 |     const { getByRole } = render(<Image />);
      141 |
    > 142 |     getByRole('image');
          |     ^
      143 |   });
      144 | });
      145 |

Versions

Latest.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions