Get element by label input value and by labels concat values#607
Get element by label input value and by labels concat values#607delca85 wants to merge 4 commits into
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 a89ec7f:
|
|
Hi @delca85! Thank you for this. This is a pretty hard problem. Unfortunately, I'm not sure that this is the right solution, but I don't know what the right solution is 😬 To compound on that, I don't have bandwidth to invest into this myself right now, so I'm calling on the rest of the @testing-library/all-maintainers (and anyone else seeing my bat signal 🦇) to come help us collaborate on a proper solution for this use case. Sorry I can't be of more help. |
|
Hi @kentcdodds! It was a pleasure for me to work on this. I would be happy to understand a bit more about the right solution so I hope your call will make someone help us! |
|
I think we can close this one now :) Thanks again! |

What:
getAllLabelsByTextnow retrieves label byinputelements not empty value toogetByLabelTextaccepts a new argument namedconcatthat enables retrieving elements by multiple concatenated labelsWhy:
According to #545 retrieving element through
inputlabels was impossible as well as using a combination of labels to get a labelled element.How:
queryAllLabelsByTextnow makes a query not only on elements of typelabelbut oninputelements too. The empty input are excluded.queryAllLabelsByTextgets the labels even if the text to be matched is a concatenation of labels, theconcatargument is passed to thematcher. Thematcherchecks the value ofconcatto decide if the condition to be satisfied is an equality or an includes (in case ofconcattrue) condition between thetextand the candidate label.textis composed by the found labelsChecklist:
inputtype to elements queried byqueryAllLabelsByTextinputelements with empty valueconcatargument to all the methods called in the chainmatcherbehavior according toconcatvaluetextto be matcheddocs site
DefinitelyTyped
Like said in #545 comments, I am not sure this is the right way to fix this wrong behavior and probably I am not considering some use case but I would like to receive some suggestions and share thoughts on it.