Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

ealmloff
Copy link
Member

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

@ealmloff ealmloff added bug Something isn't working core relating to the core implementation of the virtualdom labels Mar 22, 2024
@jkelleyrtp jkelleyrtp merged commit b19a546 into DioxusLabs:main Mar 22, 2024
7 of 9 checks passed
@ealmloff ealmloff deleted the don't-move-eventhandler-fields-props branch March 23, 2024 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core relating to the core implementation of the virtualdom
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants