-
Notifications
You must be signed in to change notification settings - Fork 470
fix: handle ignores for ByText in suggestions #597
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 29cba89:
|
Codecov Report
@@ Coverage Diff @@
## master #597 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 535 536 +1
Branches 133 133
=========================================
+ Hits 535 536 +1
Continue to review full report at Codecov.
|
964af82
to
001179b
Compare
…-testing-library into bug/suggestion-fixes
src/suggestions.js
Outdated
const textContent = normalize(element.textContent) | ||
if (textContent) { | ||
const textContent = normalize(getNodeText(element)) | ||
if (textContent && !element.matches('script, style')) { |
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.
Can't we use the same ignores that are used by the query options? I think that would be best
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.
done.
Yep will do
|
const textContent = normalize(element.textContent) | ||
if (textContent) { | ||
const textContent = normalize(getNodeText(element)) | ||
if (textContent && !element.matches(DEFAULT_IGNORE_TAGS)) { |
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.
Sorry, I don't mean it should be the default ignore but rather whatever ignore configuration was passed to the query. Is that possible?
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.
Oh that's not necessary. The only reason it would be suggesting getByText is if it got something lower down the list and afaict none of those would use ignore. And the only 2 above byText are label and role neither of which have an ignore 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.
And if you're already using text it won't suggest text again
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! Thanks 🤘
sweet, thanks @kentcdodds now to publish which-query to the chrome store. :) |
🎉 This PR is included in version 7.7.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What: properly handles
ignore
option in suggestions.Why: previously if you try to get a suggestion on a random element it would not ignore script, style tags and suggest getByText on those elements.
How:
.matches("script, style")
Checklist:
docs site
DefinitelyTyped