-
Notifications
You must be signed in to change notification settings - Fork 273
Add alias to hidden in query options #1220
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
@mdjastrzebski I've got some doubts about my jsdocs for the |
Codecov ReportBase: 94.49% // Head: 94.53% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1220 +/- ##
==========================================
+ Coverage 94.49% 94.53% +0.03%
==========================================
Files 42 42
Lines 2927 2946 +19
Branches 435 438 +3
==========================================
+ Hits 2766 2785 +19
Misses 161 161
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
src/helpers/findAll.ts
Outdated
const includeHiddenQueryOption = options?.includeHidden ?? options?.hidden; | ||
const defaultIncludeHidden = | ||
getConfig()?.defaultIncludeHidden ?? getConfig()?.defaultHidden; | ||
|
||
const hidden = options?.hidden ?? getConfig().defaultHidden; | ||
const hidden = includeHiddenQueryOption ?? defaultIncludeHidden; |
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.
const includeHidden =
options?.includeHidden ??
options?.hidden ??
getConfig()?.defaultIncludeHidden ??
getConfig()?.defaultHidden
}
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 wanted to avoid nested operators to maximise readibility, do you find it more readable your way?
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.
Yes, I find it much more readable, as a single nullish coalescing operator. Having it as separate intermediate vars would be useful if it used a mix of two operators (like &&
and ||
) with different precedence, etc. In case all vars use the same operator, I found putting it together removes the question why are there some intermediate variables :-)
@mdjastrzebski I pushed a new commit with the other naming |
@MattAgn |
@@ -239,9 +239,18 @@ test('byA11yState queries support hidden option', () => { | |||
|
|||
expect(getByA11yState({ expanded: false })).toBeTruthy(); | |||
expect(getByA11yState({ expanded: false }, { hidden: true })).toBeTruthy(); | |||
expect( |
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.
style: in our tests (also in other test files) I think it would be enough to use recommended includeHiddenElements
option name and avoid polluting them with hidden
all the time. We might want to have some few separate tests that would check that hidden
alias is also used.
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.
Or in case you find it useful the current way, just put the includeHiddenElements
first as the recommended option.
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.
extracting them in another test file sounds good :) (helped me find a bug in the process)
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 the new name includeHiddenElements
seems to strike a proper balance between being readable and concise. As they say "naming is hard" but I think you nailed it 👍🏻
Regarding usage I would make sure we emphasis the readable variant, i.e. put it first in relevant tests, examples, docs, etc.
At this stage the goal for hidden
alias is to help folks migrating from RTL or building dual RNTL/RTL wrappers. So it should work but should not be prominent at all not to confuse the main audience.
9afc0ca
to
93454f9
Compare
93454f9
to
6a1cd36
Compare
@mdjastrzebski thanks for the review, should be all good now :) I've fixed a bug I introduced as well:
That's why I added some code in the configure option to tackle that |
Co-authored-by: Maciej Jastrzebski <[email protected]>
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.
👍🏻
This PR aims to tackle this issue. Basically the idea is to add a new option
includeHidden
that will be an alias to the query optionhidden
but much clearer. We keep the old namehidden
for compatibility with RTLSummary
hidden
query option tohidden
defaultHidden
config todefaultIncludeHidden
Test plan
includeHidden
option is working for all queriesdefaultIncludeHidden
option is workingRemaining work
includeHidden
andincludeHiddenFromAccessibility
Resolves #1194