dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Inconsistent behaviour in multiple select

Open chungwong opened this issue 1 year ago • 2 comments

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

Screenshot from 2024-11-07 13-06-35

Environment:

  • Dioxus version: master

chungwong avatar Nov 07 '24 02:11 chungwong

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,
}

chungwong avatar Nov 08 '24 00:11 chungwong

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.

matthunz avatar Nov 11 '24 04:11 matthunz

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

ealmloff avatar Apr 03 '25 23:04 ealmloff