-
Notifications
You must be signed in to change notification settings - Fork 468
Fixed ByLabel queries to work with selects #451
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
Fixed ByLabel queries to work with selects #451
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 0a4ba3d:
|
Codecov Report
@@ Coverage Diff @@
## master #451 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 385 387 +2
Branches 91 91
=========================================
+ Hits 385 387 +2 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 wonder if there's a way to deal with the TextNode directly rather than try and filter out the text content of select and it's options. 🤔 Could you investigate that? Otherwise I'm fine with this for now.
It would be much better IMO. I'll have a look at this and come back with my findings 😊 |
@kentcdodds I tested this and it seems to work fine: const textToMatch = Array.from(label.childNodes)
.filter(n => n.nodeName === "#text")
.map(n => n.data)
.join('') There is a hiccup with this approach, though. It limits the usage of inline elements within the label text (like While I'm at this, I was looking at other issues/PRs (mainly this one: #372) and this seems like something desirable from the library POV. I'm not sure if this is the right place to ask this, but what is the reason behind this? EDIT: replacing |
Sorry for the delay. If you would like to make that update based on your text node version I would be willing to merge that. I'd love a review from someone else watching the repo though :) |
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.
After further investigation, I don't think my suggested "solution" will work here. So this looks good. Thank you!
🎉 This PR is included in version 6.14.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
Updating the ByLabel queries to work with
<select>
components. It didn't work properly with<select>
components because the text from the options is part of the label'stextContent
property.Why:
It seems super counter-intuitive that it works really well for other inputs (even
<textarea>
), but not for<select>
. I think having this working properly will make this library an even greater joy to use ❤️How:
I used the same strategy used for
<textarea>
components, but instead removing thetextContent
value from the<select>
components from the label'stextContent
.Checklist:
docs site
DefinitelyTyped
If anyone is having this same issue and this fix is not available, you can use this workaround:
I would also like to add that you rule for making front-end testing such a pleasant experience! ❤️