-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Problem
Before 68d2fdb, Event::stop_propogation works inside Callbacks. After that, bubbling is always enabled, even if stop_propagation is called, the ancestor's callback will still gets called.
Steps To Reproduce
minimal testing code:
use yew::prelude::*;
struct Model;
impl Component for Model {
type Message = ();
type Properties = ();
fn create(ctx: &Context<Self>) -> Self {
Self
}
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
false
}
fn view(&self, ctx: &Context<Self>) -> Html {
let parent_onclick = ctx.link().callback(|_|{
gloo_console::info!("Parent callback!");
});
let child_onclick = ctx.link().callback(|e: MouseEvent|{
gloo_console::info!("Child callback!");
e.stop_propagation();
});
html! {
<div style="height: 80px; width:80px; background-color: blue;" onclick={parent_onclick}>
<div style="height: 40px; width:40px; background-color: green;" onclick={child_onclick}/>
</div>
}
}
}
fn main() {
yew::start_app::<Model>();
}Click on the child, and the parent's callback gets called despite there is a stop_propogation.
Expected behavior
stop_propogation should stop the bubbling.
Environment:
- Yew version: [
master] - Rust version: [1.55.0]
Questionnaire
- I'm interested in fixing this myself but don't know where to start
- I would like to fix and I have a solution
- I don't have time to fix this right now, but maybe later
Reactions are currently unavailable