-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
When interacting with a child component's html, should it be treated in the whole rendered context? #983
Comments
Thanks for the issue. I will have a look into it. |
Root Cause Analysis I took the time to look into what is the problem here. First let's consider those two components: Parent: <form id="my-form" @onsubmit="() => FormSubmitted = true">
<InnerSubmitForm></InnerSubmitForm>
</form> And InnerSubmitForm: <button id="inside-form-button" type="submit" @onclick="...">Submit</button> The following test will work: var cut = RenderComponent<OuterSubmitForm>();
cut.Find("button").Click();
cut.Instance.FormSubmitted.ShouldBeTrue(); This one will fail: var cut = RenderComponent<OuterSubmitForm>();
cut.FindComponent<InnerSubmitForm>().Find("button").Click();
cut.Instance.FormSubmitted.ShouldBeTrue(); The reason lays inside else
{
LoadRenderTreeFrames(componentId, framesCollection);
result = activator.CreateRenderedComponent(componentId, component, framesCollection);
renderedComponents.Add(result.ComponentId, result);
} Basically we are creating more or less a new component that is disconnected from its past parent. So when inspecting the nodes we will see that our parent node is of type foreach (var candidate in element.GetParentsAndSelf()) |
@linkdotnet, thanks for investigating. I am not sure the conclusion is exactly correct though. The problem should not be related to the code you quote from TestRenderer, the initial call to RenderComponent will make sure the entire component tree is rendered at that point. However, when we issue a There is no straightforward fix for this.
Either way its not an easy thing to do, and probably not something that we can jump into immediately. |
I understand, it is just a strange thing a colleague of mine ran into and he struggled with it for a while. Then I started to help, look at the code and it made sense, but from his test code it was not immediately obvious what was happening as one button click would work, and the other button would not. (The latter being a submit button) |
@JelleHissink, no it's an unfortunate and annoying limitation we currently have. |
This is another issue that would be solved by #48. |
I noticed something.
When I have a form and a component containing a submit button....
Is this by design? Or is it easy to implement, or consider for V2
The text was updated successfully, but these errors were encountered: