dotnet / dotnet/aspnetcore

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

Open
#35,455 3 comments 5 reactions 0 assignees View on GitHub
area-blazor design-proposal enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

## 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](https://blazorrepl.com/repl/wFkCFClH42P3w6Os25):
```razor



Click Me

```
**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.

Contributor guide

Open the contributing guide

Research direction

Start with the linked Blazor REPL demo and reproduce the nested button behavior with event.stopPropagation() and the event:stopPropagation directive. Trace how DOM events reach Blazor handlers; done means a JavaScript event can stop propagation to third-party parent handlers without preventing Blazor handlers in the element subtree.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, html, javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.