OnClick from button inside ChildContent fails to pass a member variable into subcomponents
This is a tricky one to describe so I've created a minimal project that shows the issue.
https://github.com/JimLynn/BlazorTagHelperChildContent
What the index page wants to do is take a name and description, create an instance of a Thing class, set that as a member of the Index page, which is also used as a member of a subcomponent, called Outer. The Outer component displays the contents of the Thing.
Index has a single method, which takes the Name and Description properties, and creates a Thing, and sets its own Thing property to that new object. I would expect this to then cause the Outer component to display the new contents.
The markup for Index has two buttons. The blue button is just in the regular markup, and it calls the method to generate and set the Thing. Click on this with something in the two fields and you should see the displayed data in the Outer component change. You can do this several times with different values to see that it changes each time.
The second button, the green one, is inside another component, the WithChild component. All that does is wrap the child content of the tag in some markup. The wrapped content should be otherwise unchanged.
Here's where the bug seems to manifest. This button calls exactly the same method as the working button, but for reasons I can't fathom, setting the Thing property this time does not pass it through to the Outer component. You can see from the Console.WriteLine at the end of the method that the Thing property in Index has been set correctly, as it's echoing its properties.
So somehow, calling a method from a click inside some child content isn't behaving the same as when the same method is called in the main body of the component.
The console isn't showing any uncaught exceptions, but it feels like something is silently failing, possibly because the context is different when it's child content. Maybe the re-rendering gets stalled before the components get re-rendered.
Thanks for contacting us, @JimLynn. @javiercn, can you please look into this? Thanks!
Thanks for contacting us. We're closing this issue as there was no community involvement here for quite a while now. If you're still facing this issue with the latest Blazor bits, please reopen a new issue.