-
Notifications
You must be signed in to change notification settings - Fork 467
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
Add level
filter for treeitem
#980
Comments
aria-posinset
aria-posinset
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Not sure anymore why this was an issue. But we definitely would need to add support for computing implicit |
level
filter for treeitem
@eps1lon Am also hitting this issue as well (when applying Let me know if you're willing to accept PRs (or if this should be a separate issue). I can help add support so that |
Summary
@testing-library/jest-dom
explicitly disallows the use of thelevel
property ingetByRole
for all roles exceptheading
.This needs to be broadened as W3 also supports this property on the
treeitem
,listitem
, androw
roles.Relevant code or config:
"@testing-library/jest-dom": "^5.14.1"
"@testing-library/react": "^11.2.7"
What you did:
I am trying to select an element with
role="treeitem"
based on itslevel
. In my actual app I have the same names appearing as both a parent and a child.What happened:
The test cannot be executed due to an error:
Reproduction:
Created a CodeSandbox
Problem description:
The
aria-level
attribute and implicit levels are supported by W3 for multiple roles, as seen here:heading
listitem
row
treeitem
However
@testing-library/dom
does a validation check which only allows forlevel
to be used with theheading
role.The problematic code appears on lines 67-72 of
/src/queries/roles.js
:Suggested solution:
The code section above needs to be modified to prevent throwing the error.
The actual computation of the level property happens here. The current code will work on
treeitem
elements which use the explicitaria-level
attribute. The implicit level is based on the current item's position in the tree, so additional work needs to be done to compute the implicit level.heading
levels can be computed just from thetagName
buttreeitem
levels cannot. It would require some sort of querying of the parents and the tree.The text was updated successfully, but these errors were encountered: