DioxusLabs / dioxus

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

Dynamic rendering unresponsive for if-else-expressions where expressions are Fragments #2359

Closed fabianboesiger closed 1 week ago

fabianboesiger commented 1 week ago

Problem

The dynamic rendering of the if-expression does not work if the expressions are Fragments. If the Fragments are replaced by divs, everything works as expected.

Steps To Reproduce

In the following example, the paragraph does not update to "input not empty" as it should.

#![allow(non_snake_case)]

use dioxus::prelude::*;

fn main() {
    launch(App);
}

fn App() -> Element {
    let mut signal = use_signal(|| String::new());

    rsx! {
        input {
            value: signal(),
            oninput: move |evt| {
                signal.set(evt.value());
            }
        }
        if signal().is_empty() {
            Fragment {
                p { "input empty!" }
            }
        } else {
            Fragment {
                p { "input not empty!" }
            }
        }
    }
}

Expected behavior

The rendered content should be updated if the signal is updated and is not empty.

Environment: