-
Notifications
You must be signed in to change notification settings - Fork 471
feat(ByRole): Allow filter by selected state #540
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
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 62928cf:
|
Codecov Report
@@ Coverage Diff @@
## master #540 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 438 452 +14
Branches 105 111 +6
=========================================
+ Hits 438 452 +14
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this is going 👍 Just one question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! Let's get docs ready and then we can get this merged.
🎉 This PR is included in version 7.4.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
Allows to filter results of
ByRole
by theiraria-selected
state viagetByRole(role, { selected: true })
.There were some concerns allowing filtering by aria attributes (can't find the issue anymore) since users could mistakenly add them arbitrarily to create selectors that look accessible while creating broken UIs.
This is why I think we should restrict filter options to attributes that are only allowed on certain roles.
For example, I wouldn't implement1. If people want to filter by aria attributes on arbitrary elements then they always have thegetByRole(role, { disabled: true })
sincearia-disabled
is a global attribute i.e. can be applied to any elementgetAllByRole(...).filter()
escape hatch.1 I was looking at aria-disabled in ARIA 1.1. It is restricted to certain elements in 1.2. The gist still applies.
Why:
Spec-compliant convenience wrapper around
getAllByRole(role).filter(el => el.getAttribute('aria-selected') === "true")
How:
aria-selected
selected
if the role does not support this attributeChecklist:
docs site: docs(ByRole): Add { selected: boolean } option testing-library-docs#458
DefinitelyTyped