Skip to content

Conversation

@azriel91
Copy link
Contributor

@azriel91 azriel91 commented Oct 4, 2025

Allows you to do this:

#[component]
pub fn MyDetails() -> impl IntoView {
    let (expanded, expanded_set) = leptos::prelude::signal(true);
    view! {
        <details
            open={move || expanded.get()}
            on:toggle=move |event| *expanded_set.write() = event.new_state() == "open"
        >
            <summary><OneLineSummary expanded /></summary>
            <p>contents</p>
        </details>
    }
}

#[component]
#[component]
pub fn OneLineSummary(expanded: ReadSignal<bool>) -> impl IntoView {
    view! {
        <span>{move || if expanded.get() { "Long text" } else { "short" }}</span>
    }
}
@gbj gbj added this to the 0.9 milestone Oct 7, 2025
@gbj
Copy link
Collaborator

gbj commented Oct 7, 2025

Thanks! As you note, unless I'm mistaken this is a breaking change. Which is not a judgment of how large or small a change it is, simply the fact that including this in a patch release would cause previously-working code to stop compiling, which is bad. I'm fine making the change in 0.9.

In the meantime, you can use the JsCast trait from wasm-bindgen to convert to ToggleEvent pretty easily:

*expanded_set.write() = event.unchecked_ref::<ToggleEvent>().new_state() == "open"
@azriel91
Copy link
Contributor Author

azriel91 commented Oct 7, 2025

ah! Thanks for the tip, I really appreciate both short and long term solutions 🙏

@gbj gbj added the breaking label Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants