My event is not called in the parent component when using EventCallBack in a child component.
I've already been through #12116 and #8385 but It still not working
My code:
Tree.razor (child)
@typeparam TNode
<HTML WITH DOUBLECLICK EVENT>
@code{
[Parameter] public EventCallback<DoubleClickVariableEventArgs> OnDoubleClickOnVariable { get; set; }
private void OnDoubleClickTree(object sender, MouseEventArgs e)
{
Console.WriteLine("TEST");
OnDoubleClickOnVariable.InvokeAsync(new DoubleClickVariableEventArgs(selectedNode.Path, selectedNode.IsReadOnly));}
}
"TEST" is correctly displayed in the console. so the problem is from InvokeAsync.
My eventargs:
public class DoubleClickVariableEventArgs : EventArgs
{
public DoubleClickVariableEventArgs(string path ,bool isReadOnly)
{
Path = path;
IsReadOnly = isReadOnly;
}
public string Path { get; private set; }
public bool IsReadOnly { get; private set; }
}
MAIN.razor (parent)
<Tree TNode="TreeItem" Nodes="Items" ChildSelector="@(item => item.Childs)" @bind-SelectedNode="selectedNode" @bind-ExpandedNodes="ExpandedNodes" HasChildNodes="@(item => item.Childs?.Any() == true)" OnDoubleClickOnVariable="OnVariableDoubleClick">
<TitleTemplate>@context.Text</TitleTemplate>
</Tree>
@code{
private async Task OnVariableDoubleClick(DoubleClickVariableEventArgs e)
{
Console.WriteLine("TEST2");
}
}
I tried some of the solutions like writing the type : TNode = "TreeItem" or writing OnDoubleClickOnVariable="(DoubleClickVariableEventArgs x) => OnVariableDoubleClick(x)" Without success...
I want to say that I used the exact same structure in another non-generic component and it's working perfectly.
Lastest Blazor, VS Preview versions
P.S. On of my first post on github sorry if it's unreadable
@Flearz thanks for contacting us.
@rynowak can you take a look at this and see if there's an issue?
I'm having the same issue...
@Flearz Can you upload your reproduction to a GitHub repository?
I've tried to create a simple repro with a generic component that accepts an event callback and do see the InvokeAsync is called in my sample.
There maybe something else in your application that is causing the issue so a repro will help.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
See our Issue Management Policies for more information.
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.
This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!
Most helpful comment
I'm having the same issue...