Skip to content

A select apparently loses its state? #2888

Closed Answered by gbj
huuff asked this question in Q&A
Discussion options

You must be logged in to vote

I'm going to guess your issue here is that every time the number of items changes, it rerenders all the <option> elements, and that unmounting and remounting those all resets the value in the <select>, but I'm not sure. Maybe try a keyed list with <For/> rather than the unkeyed iteration you're doing at present.

I'm talking about things like this in case it's not clear

{move || {
    (1..=days_in_month())
        .map(|day| view! { <option value=day>{day}</option> })
        .collect_view()
}}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by huuff
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants