Open egil opened 1 year ago
@egil The given scenario in the referenced ticket doesn't necessarily need walking up the render tree. We could offer a "global" FindComponent/Find that directly starts from our Bunit RootComponent.
Through ComponentState, we have the ability to walk up the tree in .NET 8. I do think this is valuable to expose. Maintaining af collection of children may not be worth it with FindComponent.
Right now an IRenderedFragment/IRenderedComponent allows users to search for any child complements. However as https://github.com/telerik/blazor-ui/pull/259#issuecomment-1678477209 suggests, it can be useful to go to the root component and parent component.
Much like the DOM api, I think we can expose the following:
There are a few problems here though.
IReadOnlyList<RenderedComponent<T>>
from the Children's method/property because T is not the necessary the same type. There could be a genericIReadOnlyList<RenderedComponent<T>> GetChildren<T>
that behaves likeFindComponents<T>
does (except it just searches children and not children's children), and a non-genericIReadOnlyList<RenderedFragment> Children
property that returns all children which children.Neither of these API changes would be conflicting with the FindComponents depth first search methods, so that's a nice bonus.