Skip to content

show component cannot properly handle its children state #4005

@sabify

Description

@sabify

Describe the bug
When I try to set prop:value for a select input while using show component, it won't take the changes into effect.

Leptos Dependencies
The latest leptos commit: 07cf649

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project with cargo leptos new -g leptos-rs/start-axum.
  2. Change HomePage component to:
#[component]
fn HomePage() -> impl IntoView {
    let counter = Store::new(Counter { count: 1 });
    let (show, set_show) = signal(false);
    let (available_numbers, _) = signal(vec![0, 1, 2]);
    view! {
        <Show when=move || show.get()>
            <form>
                <select
                    on:change:target=move |ev| {
                        counter.count().update(|c| *c = ev.target().value().parse().unwrap());
                    }
                    prop:value=move || counter.count().get().to_string()
                >
                    <option value="">"select"</option>
                    <For each=move || available_numbers.get() key=|c| *c let(number)>
                        <option value=number.to_string()>{number.to_string()}</option>
                    </For>
                </select>
            </form>
        </Show>

        <button on:click=move |_| {
            set_show.update(|s| *s = !*s);
        }>"Show"</button>
    }
}
  1. Serve the app and click on show.
  2. See select wrongly in the select input. The number 1 should be shown in the select input. Please consider that the behavior without the show component is correct and properly shows 1 in the select input.

Next Steps
[ ] I will make a PR
[x] I would like to make a PR, but need help getting started
[x] I want someone else to take the time to fix this
[ ] This is a low priority for me and is just shared for your information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions