MultiSelect without closing

Hi,

When you are using multiselect, user has to select, click to multi select again and select again. I think, for best user experience, multi-select dropdown menu should be open unless user clicks somewhere else. Imagine you have to select 10 options, it is 20 click (10 options + 10 for opening the menu) instead of 11 click (one for opening the menu and 10 options).

Is there an option to do this that I am not aware of?

2 Likes

If you have a few number of options, you could try using a collection of check boxes instead.

Cheers

@Berk_Demir did you find any solution to this?

1 Like

Hi @kee ,

it looks like this is not available as of right now but if you install streamlit-nightly(streamlit-nightly · PyPI), then you can get these changes right away.

In addition, if you are willing to wait, this will be released in the next release which should occur next wednesday so be out on the lookout for the next release :slight_smile:

Happy streamlitting!

:balloon:

1 Like

thanks @willhuang . I am experimenting now with the nightly build. Is there a particular argument I need to pass to st.multiselect(...) to enable this behavior?

I do see the addition of max_selections in the underlying class in the nightly build - and while I did track down some references to being able to keep the selector open, I’m not sure how to enable that.

class MultiSelectMixin:
    @gather_metrics
    def multiselect(
        self,
        label: str,
        options: OptionSequence[T],
        default: Optional[Any] = None,
        format_func: Callable[[Any], Any] = str,
        key: Optional[Key] = None,
        help: Optional[str] = None,
        on_change: Optional[WidgetCallback] = None,
        args: Optional[WidgetArgs] = None,
        kwargs: Optional[WidgetKwargs] = None,
        *,  # keyword-only arguments:
        disabled: bool = False,
        label_visibility: LabelVisibility = "visible",
        max_selections: Optional[int] = None,

@kee , thanks for installing the nightly :slight_smile:

As for whether or not you need to enable anything, I think it should automatically be enabled.

I just tested this specific code on a deployed streamlit app that should have at least the new multiselect feature code:

options = ("male", "female")

i1 = st.multiselect("multiselect 1", options)
st.text(f"value 1: {i1}")

and it looks like I get the behavior.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.