fix event tests in core

This commit is contained in:
Evan Almloff committed 2024-01-04 19:32:00 -06:00
1 parent 0388a5c1f4
commit fae81e2364
2 files changed
+7 -11

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ fn app(cx: Scope) -> Element {
button {
onclick: move |_| {
let dom = VirtualDom::new_with_props(compose, ComposeProps { app_tx: tx.clone() });
window.new_window(dom, Default::default());
dioxus_desktop::window().new_window(dom, Default::default());
},
"Click to compose a new email"
}
+6 -10
View File
@@ -10,7 +10,7 @@ fn events_propagate() {
_ = dom.rebuild();
// Top-level click is registered
dom.handle_event("click", Rc::new(MouseData::default()), ElementId(1), true);
dom.handle_event("click", Rc::new(PlatformEventData::new(Box::<SerializedMouseData>::default())), ElementId(1), true);
assert_eq!(*CLICKS.lock().unwrap(), 1);
// break reference....
@@ -20,7 +20,7 @@ fn events_propagate() {
}
// Lower click is registered
dom.handle_event("click", Rc::new(MouseData::default()), ElementId(2), true);
dom.handle_event("click", Rc::new(PlatformEventData::new(Box::<SerializedMouseData>::default())), ElementId(2), true);
assert_eq!(*CLICKS.lock().unwrap(), 3);
// break reference....
@@ -30,14 +30,13 @@ fn events_propagate() {
}
// Stop propagation occurs
dom.handle_event("click", Rc::new(MouseData::default()), ElementId(2), true);
dom.handle_event("click", Rc::new(PlatformEventData::new(Box::<SerializedMouseData>::default())), ElementId(2), true);
assert_eq!(*CLICKS.lock().unwrap(), 3);
}
fn app(cx: Scope) -> Element {
render! {
div {
onclick: move |_| {
div { onclick: move |_| {
println!("top clicked");
*CLICKS.lock().unwrap() += 1;
},
@@ -53,17 +52,14 @@ fn app(cx: Scope) -> Element {
fn problematic_child(cx: Scope) -> Element {
render! {
button {
onclick: move |evt| {
button { onclick: move |evt| {
println!("bottom clicked");
let mut clicks = CLICKS.lock().unwrap();
if *clicks == 3 {
evt.stop_propagation();
} else {
*clicks += 1;
}
}
}
} }
}
}