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

Provide query option to respect accessibility #970

Closed
mdjastrzebski opened this issue May 4, 2022 · 6 comments · Fixed by #1064
Closed

Provide query option to respect accessibility #970

mdjastrzebski opened this issue May 4, 2022 · 6 comments · Fixed by #1064
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mdjastrzebski
Copy link
Member

mdjastrzebski commented May 4, 2022

Describe the Feature

This issue is based on #787 PR. That PR is stale but idea seems worth pursuing.

Currently all queries ignored accessibility ignored the fact that certain element, e.g. screen or modal is present in component tree but not really visible to the user.

This problem largely does not exist in web React world as previous screens are removed from component tree, except modals, but it is relevant in React Native world. We even suggest some work arounds for it with within function.

Possible Implementations

  • Add additional respectAccessibility query options for all queries. This query options would be common to all query verbs (getBy, etc) and predicates (byText, etc).
  • By default it should be disabled to preserve API stability
  • If set explicitly to true it would ignore elements that are not accessible, by analysing e.g. accessibilityElementsHidden, importantForAccessibility, accessibilityViewIsModal, style={{ display: 'none' }}, etc
  • Consider switching this option to true by default by introducing a breaking change in next major release, as having it on by default is probably what users would expect.
  • We could salvage some a11y predicate code and possibly all tests from feat: accessibility findAll #787

Related Issues

@mdjastrzebski mdjastrzebski added help wanted Extra attention is needed good first issue Good for newcomers feature request labels May 4, 2022
@mdjastrzebski
Copy link
Member Author

@thymikee @AugustinLF any thoughts on the above?

@thymikee
Copy link
Member

thymikee commented May 4, 2022

I'm in favor. However, I'd see this as a temporary solution until we're sure about the way it works is in a perfect sync with how react-native treats those accessibility traits. We should make it explicit from the beginning when documenting the feature.

@mdjastrzebski
Copy link
Member Author

As in all other cases like queries we are doing our best but only imperfectly simulate RN runtime environment.

RTL for web can rely on JS DOM to have a very real-like environment so it has a much simpler work in that regard.

@AugustinLF
Copy link
Collaborator

The path you outline sounds worth pursuing IMO.

@MattAgn
Copy link
Collaborator

MattAgn commented Jul 27, 2022

I would also love to have that feature! @mdjastrzebski Can I help finishing the implementation?

@mdjastrzebski
Copy link
Member Author

@MattAgn please do! 💯 This would be a very useful feature to have in RNTL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants