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

Blazor: Problem with EventCallBack in Generic component #17480

Closed
Flearz opened this issue Nov 28, 2019 · 5 comments
Closed

Blazor: Problem with EventCallBack in Generic component #17480

Flearz opened this issue Nov 28, 2019 · 5 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components question
Milestone

Comments

@Flearz
Copy link

Flearz commented Nov 28, 2019

Describe the bug

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

To Reproduce

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.

Further technical details

Lastest Blazor, VS Preview versions

P.S. On of my first post on github sorry if it's unreadable

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components investigate labels Nov 28, 2019
@javiercn
Copy link
Member

@Flearz thanks for contacting us.

@rynowak can you take a look at this and see if there's an issue?

@mkArtakMSFT mkArtakMSFT added this to the 5.0.0-preview1 milestone Dec 3, 2019
@partyelite
Copy link

partyelite commented Dec 18, 2019

I'm having the same issue...

@captainsafia
Copy link
Member

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

@captainsafia captainsafia added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. question and removed investigate labels May 8, 2020
@ghost
Copy link

ghost commented May 12, 2020

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.

@ghost ghost removed Status: No Recent Activity Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels May 15, 2020
@ghost
Copy link

ghost commented Jul 14, 2020

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!

@ghost ghost closed this as completed Jul 14, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Aug 13, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components question
Projects
None yet
Development

No branches or pull requests

6 participants