Skip to content

[Coming soon] Persist widget identity when key is set, even if the parameters change #11277

@jrieke

Description

@jrieke

Checklist

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

Summary

If you change any parameter of a widget in Streamlit (e.g. the label or the default value), Streamlit will treat it as a new widget and reset its state. That’s necessary because we determine which widget state belongs to which widget based on the parameters. (Note that there are a few exceptions to this rule, e.g. changing the disabled parameter will not reset the widget).

But we still do this when you manually set key! Even though in that case, we can easily associate the widget state with the widget based on the key. We should change that and always preserve the widget identity if key is set.

Why?

This (potentially) fixes lots of small issues such as:

How?

We need to be careful here since this might break apps. Probably needs a bit of investigation.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:widgetsRelated to widget elementstype: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