Skip to content

bind="query-params" doesn't add the the value to query string if the default value is chosen #16055

Description

@zcabaal

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

Binding query params doesn't add the value to the url query string if the default is chosen

For example, in

import streamlit as st


st.selectbox(
    "Choose an option:",
    ["Option1", "Option2", "Option3"],
    index=0,
    bind="query-params",
    key="key1",
)


st.multiselect(
    "Choose an option or more:",
    ["Option1", "Option2", "Option3"],
    default=["Option1"],
    bind="query-params",
    key="key2",
)

In both widget, selecting Option1 will remove the value from the query string.
If I select Option2, it gets added to the url query string, but if I select Option1 again it get removed

I would like the default to be added in the url (or have a parameter that enables this behaviour). In dymanic apps where options and default values can change, being able to share a url containing all values (including those set to the default value), will ensure that the shared url always contains the same values even if the defaults change

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: 1.59.2
Python version: 3.13.13
Operating System: Ubuntu 24.04
Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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