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

Enable walking component tree #1180

Open
Tracked by #962
egil opened this issue Aug 15, 2023 · 2 comments
Open
Tracked by #962

Enable walking component tree #1180

egil opened this issue Aug 15, 2023 · 2 comments
Labels
enhancement New feature or request needs design More design is needed before this issue should result in a feature being implemented.

Comments

@egil
Copy link
Member

egil commented Aug 15, 2023

Right now an IRenderedFragment/IRenderedComponent allows users to search for any child complements. However as telerik/blazor-ui#259 (comment) 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:

Children/GetChildren()
Parent?
Root

There are a few problems here though.

  1. Should we have these as properties of methods. While the component tree is static after each render, there is an overhead in creating RenderedFragment objects for each component in the component tree before they are needed which is the obvious approach with properties.
  2. We cannot meaningfully return an IReadOnlyList<RenderedComponent<T>> from the Children's method/property because T is not the necessary the same type. There could be a generic IReadOnlyList<RenderedComponent<T>> GetChildren<T> that behaves like FindComponents<T> does (except it just searches children and not children's children), and a non-generic IReadOnlyList<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.

@egil egil added needs design More design is needed before this issue should result in a feature being implemented. enhancement New feature or request labels Aug 15, 2023
@egil egil mentioned this issue Jan 12, 2024
Closed
18 tasks
@linkdotnet
Copy link
Sponsor Collaborator

@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.

@egil
Copy link
Member Author

egil commented Mar 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs design More design is needed before this issue should result in a feature being implemented.
Projects
None yet
Development

No branches or pull requests

2 participants