Skip to content
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

fix: handle ignores for ByText in suggestions #597

Merged
merged 8 commits into from May 31, 2020

Conversation

benmonro
Copy link
Member

@benmonro benmonro commented May 30, 2020

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:

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 30, 2020

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:

Sandbox Source
epic-tree-el53k Configuration

@codecov
Copy link

codecov bot commented May 30, 2020

Codecov Report

Merging #597 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #597   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines          535       536    +1     
  Branches       133       133           
=========================================
+ Hits           535       536    +1     
Impacted Files Coverage Δ
src/queries/text.js 100.00% <ø> (ø)
src/config.js 100.00% <100.00%> (ø)
src/query-helpers.js 100.00% <100.00%> (ø)
src/suggestions.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95bb7f2...29cba89. Read the comment docs.

const textContent = normalize(element.textContent)
if (textContent) {
const textContent = normalize(getNodeText(element))
if (textContent && !element.matches('script, style')) {
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@benmonro
Copy link
Member Author

benmonro commented May 31, 2020 via email

const textContent = normalize(element.textContent)
if (textContent) {
const textContent = normalize(getNodeText(element))
if (textContent && !element.matches(DEFAULT_IGNORE_TAGS)) {
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Thanks 🤘

@kentcdodds kentcdodds merged commit bec190b into master May 31, 2020
@kentcdodds kentcdodds deleted the bug/suggestion-fixes branch May 31, 2020 03:20
@benmonro
Copy link
Member Author

sweet, thanks @kentcdodds now to publish which-query to the chrome store. :)

@kentcdodds
Copy link
Member

🎉 This PR is included in version 7.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants