Skip to content

Fixing state management issues with Streamlit's st.pills component where selections get reset when available options change dynamically and pills require double-clicks to toggle #12392

@bartekkuzma

Description

@bartekkuzma

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

I’m experiencing state management issues with st.pills when the available options change dynamically based on other user selections. The main problems are:

Double-click requirement: When something is already selected, I need to click twice on pills to toggle them

State reset: When I add new selections in a parent category that changes available options in child categories, previously selected items in child categories get reset/cleared

Use Case
I have a hierarchical selection UI:

Device Types (st.pills) → determines available Model Groups

Model Groups (st.pills) → determines available Model Numbers

Model Numbers (st.pills)

When a user selects additional device types, new model groups become available, but previously selected model groups/numbers get cleared.

Expected Behavior
Single click should toggle pill selection

When parent selections change and new options become available, previously selected items that are still valid should remain selected

Only invalid selections (no longer available) should be cleared

Reproducible Code Example

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.feedbackRelated to the `st.feedback` widgetfeature:st.pillsRelated to the `st.pills` widgetfeature:st.segmented_controlRelated to the `st.segmented_control` widgettype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions