DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.35k stars 740 forks source link

Don't move over event handler fields when diffing props #2129

Closed ealmloff closed 3 months ago

ealmloff commented 3 months ago

Follow up to #2126 to fix this test case:

fn app() -> Element {
    let mut enabled = use_signal(|| false);

    rsx!(
        ScrollThumb {
            clicking_scrollbar: enabled(),
            onmousedown: move |_| enabled.toggle(),
        }
    )
}

#[allow(non_snake_case)]
#[component]
pub fn ScrollThumb(
    clicking_scrollbar: bool,
    onmousedown: EventHandler<MouseEvent>,
) -> Element {
    rsx!(
        rect {
            onmousedown: move |e| {
                onmousedown.call(e);
            },
            width: "100%",
            height: "100%",
            background: "black",
        }
    )
}

We were manually updating event handlers in place and moving over the event handlers from the old to new props. This PR only updates the event handlers in place which fixes the issue