This commit is contained in:
Maurice Kayser 2023-01-01 21:41:18 +01:00 committed by GitHub
parent fd86420c08
commit c8f88b6428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 23 deletions

View file

@ -14,7 +14,7 @@ fn App(cx: Scope) -> Element {
button {
onclick: move |event| {
// now, outer won't be triggered
event.stop_propogation();
event.stop_propagation();
},
"inner"
}

View file

@ -16,18 +16,18 @@ fn app(cx: Scope) -> Element {
onclick: move |_| println!("clicked! top"),
"- div"
button {
onclick: move |_| println!("clicked! bottom propoate"),
"Propogate"
onclick: move |_| println!("clicked! bottom propagate"),
"Propagate"
}
button {
onclick: move |evt| {
println!("clicked! bottom no bubbling");
evt.stop_propogation();
evt.stop_propagation();
},
"Dont propogate"
"Dont propagate"
}
button {
"Does not handle clicks - only propogate"
"Does not handle clicks - only propagate"
}
}
})

View file

@ -35,13 +35,13 @@ fn app(cx: Scope) -> Element {
nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center" }
button {
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| window.set_minimized(true),
"Minimize"
}
button {
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| {
window.set_fullscreen(!**fullscreen);
@ -52,7 +52,7 @@ fn app(cx: Scope) -> Element {
}
button {
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| window.close(),
"Close"
}
@ -66,7 +66,7 @@ fn app(cx: Scope) -> Element {
div {
button {
class: "inline-flex items-center text-white bg-green-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| {
window.set_always_on_top(!always_on_top);
always_on_top.set(!always_on_top);
@ -77,7 +77,7 @@ fn app(cx: Scope) -> Element {
div {
button {
class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| {
window.set_decorations(!decorations);
decorations.set(!decorations);
@ -88,7 +88,7 @@ fn app(cx: Scope) -> Element {
div {
button {
class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
onmousedown: |evt| evt.stop_propogation(),
onmousedown: |evt| evt.stop_propagation(),
onclick: move |_| window.set_title("Dioxus Application"),
"Change Title"
}

View file

@ -23,7 +23,7 @@ use std::{
pub struct Event<T: 'static + ?Sized> {
/// The data associated with this event
pub data: Rc<T>,
pub(crate) propogates: Rc<Cell<bool>>,
pub(crate) propagates: Rc<Cell<bool>>,
}
impl<T> Event<T> {
@ -40,9 +40,9 @@ impl<T> Event<T> {
/// }
/// }
/// ```
#[deprecated = "use stop_propogation instead"]
#[deprecated = "use stop_propagation instead"]
pub fn cancel_bubble(&self) {
self.propogates.set(false);
self.propagates.set(false);
}
/// Prevent this event from continuing to bubble up the tree to parent elements.
@ -58,8 +58,8 @@ impl<T> Event<T> {
/// }
/// }
/// ```
pub fn stop_propogation(&self) {
self.propogates.set(false);
pub fn stop_propagation(&self) {
self.propagates.set(false);
}
/// Get a reference to the inner data from this event
@ -84,7 +84,7 @@ impl<T> Event<T> {
impl<T: ?Sized> Clone for Event<T> {
fn clone(&self) -> Self {
Self {
propogates: self.propogates.clone(),
propagates: self.propagates.clone(),
data: self.data.clone(),
}
}
@ -100,7 +100,7 @@ impl<T> std::ops::Deref for Event<T> {
impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("UiEvent")
.field("bubble_state", &self.propogates)
.field("bubble_state", &self.propagates)
.field("data", &self.data)
.finish()
}

View file

@ -499,7 +499,7 @@ impl<'src> ScopeState {
BumpBox::from_raw(self.bump().alloc(move |event: Event<dyn Any>| {
if let Ok(data) = event.data.downcast::<T>() {
callback(Event {
propogates: event.propogates,
propagates: event.propagates,
data,
})
}

View file

@ -347,7 +347,7 @@ impl VirtualDom {
// We will clone this later. The data itself is wrapped in RC to be used in callbacks if required
let uievent = Event {
propogates: Rc::new(Cell::new(bubbles)),
propagates: Rc::new(Cell::new(bubbles)),
data,
};
@ -388,7 +388,7 @@ impl VirtualDom {
cb(uievent.clone());
}
if !uievent.propogates.get() {
if !uievent.propagates.get() {
return;
}
}

View file

@ -170,7 +170,7 @@ impl<T> UseRef<T> {
/// Set the curernt value to `new_value`. This will mark the component as "dirty"
///
/// This change will propogate immediately, so any other contexts that are
/// This change will propagate immediately, so any other contexts that are
/// using this RefCell will also be affected. If called during an async context,
/// the component will not be re-rendered until the next `.await` call.
pub fn set(&self, new: T) {