-
Notifications
You must be signed in to change notification settings - Fork 470
feat(ByRole): Allow filter by value state #1223
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 c9a2416:
|
c1666a0
to
29f9277
Compare
Codecov Report
@@ Coverage Diff @@
## main #1223 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 999 1035 +36
Branches 323 346 +23
=========================================
+ Hits 999 1035 +36
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
daf92b3
to
29f9277
Compare
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.
One small nit, but can be ignored if you want.
if (valueNow !== undefined) { | ||
// guard against unknown roles | ||
if ( | ||
allRoles.get(role as ARIARoleDefinitionKey)?.props['aria-valuenow'] === |
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.
What do you think about declaring a variable for allRoles.get(role as ARIARoleDefinitionKey)
?
It seems like this is repeated a few times in this meethod.
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'm fine with repeating stuff. Makes it easier to grok the flow for a single option. If we change this pattern often we can reconsider but for now it seems like it's just an excercise in clean code.
Part of a larger committment to unify APIs for
/react-native
and/react
(which is just/react-dom
at the moment)What:
Enables
ByRole(role, { value })
Note that we don't support
valuenow
but rathervalue.now
(same pattern for otheraria-value*
attributes). One reason is parity with@testing-library/react-native
.The other reason is that
value.*
works a bit different in that it looks at allvalue.*
and combines them with&&
instead of returning on the first match. Today,{ pressed: true, selected: true}
has kind of an odd behavior since it only looks at whatever comes first in the implementation. We could combine them with&&
as well but it's not clear to me yet that this is always good. So by putting them in a single object makes it clear that we look at the whole object which wouldn't be that obvious for{ name, valuemin, valuemax}
. I don't feel too strongly about this specific rationale. I care more about parity with /react-native.Why:
Makes writing tests for react-native and react-dom easier by removing barriers when changing the target platform that's being tested.
How:
Same patterns as for expanded, selected etc
Checklist: