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.5k stars 10.04k forks source link

How to stop propagation of HTML DOM event without breaking nested components? #35455

Open Liero opened 3 years ago

Liero commented 3 years ago

Summary

  1. event:stopPropagation directive does not affect HTML DOM events.
  2. stopPropagation() on HTML DOM event breaks Blazor event handlers in the element's subtree:

    see live demo:

    <div onclick="event.stopPropagation()">
         <!-- TestClick is never invoked -->
         <button @onclick="TestClick">Click Me</button>
    </div>

    Is there any way to stopPropagation of JS event without breaking blazor functionality?

Motivation

I have some 3rd party javascript event handlers on the parent component. I some cases, I don't want the DOM events to propagate to them.

pranavkm commented 3 years ago

We don't have a great solution for this in Blazor today. One possible way to solve this class of issue is to remove event delegation from Blazor. Parking this in our 7.0 planning to investigate this.

ghost commented 3 years 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.

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.