dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.43k stars 10.01k forks source link

Please add ElementId to events #49301

Open mrpmorris opened 1 year ago

mrpmorris commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

Imaging a tree view component, where each item has an @onclick=ToggleExpandedAsync.

The click event is triggered on both the element clicked, and also its parent node - causing both to collapse.

I could use @onclick:stopPropagation, but a pop-up menu component that listens for all clicks outside of its own area will not see the click and cannot now know when to automatically close itself.

Describe the solution you'd like

Add public string? ElementId { get; } to the various event args (keyboard, mouse, etc), which is populated by the Id of the element that triggered the event.

Additional context

Not sure what you'd do when a composite part of the element is interacted with. Possibly have the Blazor code walk up the parent tree until it found an Id?

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

gragra33 commented 1 year ago

Why wouldn't you pass the item and EventArgs to the method?

@onclick="(e) => ToggleExpandedAsync(item, e)"

This follows the old event pattern:

void ToggleExpandedAsync(object sender, EventArgs e) { }
ghost commented 11 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.