Inconsistent behaviour in multiple select
Problem
For some reasons, if the value of multiple is a boolean, then the behaviour is wrong, default selection should not happen.
Steps To Reproduce
fn app() -> Element {
rsx! {
select {
multiple: "true",
option { label: "Brand", value: "2" }
}
select {
multiple: true,
option { label: "Brand", value: "2" }
}
}
Screenshots
Environment:
- Dioxus version: master
Just to add more context to the issue. The followings behave the same. so the issue is something different.
select {
multiple: true.to_string(),
}
select {
multiple: if true { "true" } else { "false" },
}
select {
multiple: true,
}
Hmm strange ”true” is treated differently than ”true”.to_string() (or the other examples you gave) 🤔
That makes me think this is an issue for dynamic attributes in RSX, since string literals are handled differently as static attributes.
I think this is just odd browser behavior. The first version works because the template is unmounted when multiple is set. The dynamic versions keep the selected value from the dropdown version of the element when multiple is set.
We can override the behavior of the multiple attribute to make this more predictable. It looks like react has a whole file for select edge cases like this