-
Notifications
You must be signed in to change notification settings - Fork 273
Nested custom Text componentns not working correctly #515
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
Comments
One question more, If I set |
Yup, this is an edge case we don't handle at the moment. Please feel free to send a PR fixing that :)
It's because |
Ok I will try Thank you :) |
This bug is related to a recursive way of find text node in this library. const matches = testingLib.getAllByText(text);
const element = matches[matches.length - 1]; |
Trying to match across nested nodes in an attempt to match what the user sees is an issue for several of our tests too. Most notably when we try to fire an event on an inner Text node. Right now I can't think of a way to achieve this nested matching and the specific matching behaviour beforehand. Landing #573 would at least give us a way to implement our own overrides, but long term WDYT of adding a matching option to We would have to think about how the |
We could still support nested Texts by traversing up the tree once the original query fail. If the direct parents are Text nodes, we could go up to the first one, construct the string and match using the specified matcher/normalizer. What do you think? |
I'm not sure I follow. Is this the kind of algorithm you had in mind?
|
Yea, something like this. |
I tried it and found the following problems: It is somewhat complicated by the native view being wrapped with a It matches 2 instances in this case: <Text>
<CustomText>Hello</CustomText> <CustomText>World!</CustomText>
</Text> Reversing the search method like this matches the lowest level element, not its parent, because when searching the |
We only care about host (native) components, with I was rather thinking of building a separate tree of host components while searching for the lowest Text node. If the search fails we have the tree which we can then traverse up for finding the Text that's furthest away from the leaf text node, and then construct the text based on its children. |
This sounds like some effort needs to go into this feature. I personally don't need it, what I need is parity with v6 for getByText, which is why I suggested bringing back the simple get text node implementation and having the current smarter implementation behind a flag. |
Fixed (I believe as part of #489). |
Describe the bug
If custom
Text
components are nested and find with text, then the wrong other element is retrieved.Steps to Reproduce
Versions
The text was updated successfully, but these errors were encountered: