bUnit icon indicating copy to clipboard operation
bUnit copied to clipboard

Allow components without ChildContent to be added to RenderTree

Open egil opened this issue 2 years ago • 2 comments

Users sometimes need to add mandatory components into the render tree that does not have a ChildContent parameter.

The RenderTree currently only allows adding components that has a ChildContent property, but that is an arbitrary limitation we can work around.

Now, if you call RenderTree.Add, the component is added as a child of the previous component.

However, I see no downside in allowing RenderFragments in general to be added to the render tree.

IFF a component with a ChildContent is added, then any other components or fragments will be added as children under that. If not, they are added at the root.

There are probably some edge cases I haven't thought about, so lets discuss first.

egil avatar Aug 15 '23 14:08 egil

In general, I am on your side, the only open question for me is this:

Users sometimes need to add mandatory components into the render tree that does not have a ChildContent parameter.

This seems more related to 3rd party components, where creating stubs might be the better approach. Or do you have an example at hand?

linkdotnet avatar Aug 15 '23 15:08 linkdotnet

It's a pattern I saw in some test code. I think the component being added was a popup content placeholder which was accessed via the services collection by child components.

And yes, more likely in scenarios that involves 3rd party components.

egil avatar Aug 15 '23 15:08 egil