Skip to content

st.multiselect - filter function option #15110

@dkrasne

Description

@dkrasne

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

Add the ability to filter st.multiselect menu with a function applied, so that the options are passed through the function before checking matches with the entered string -- similar to case-insensitivity (which is automatically applied), but where the issue isn't to do with case. This would be similar to Python's sorting key.

Why?

I have multiselects where the display strings and values have letters with macrons (e.g., ē), and they need to retain these. However, they should still be found if the user types the same letter without a macron (e.g., just e). Currently, this does not happen, but if I could apply a function to strip the macrons before matching, then it would work. (The same ability to apply a function would be useful for multiselects where the display string is in a non-Latin alphabet but the user might be typing transliterated characters, or where one wants to use regex to enable true fuzzy matching, so this is not a limited use case.)

How?

Add a parameter filter_func to st.multiselect that would specify the function (possibly also add a "function" option to filter_mode, but I think it wouldn't even need to change, since the fuzzy/prefix/contains could still apply). This would work just like the key parameter in .sorted() and the Pandas .sort_values() methods.

Additional Context

An example -- if I were to type 'i' as the next letter, I wouldn't get fīō as a match:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.multiselectRelated to the `st.multiselect` widgettype:enhancementRequests for feature enhancements or new features

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions