Skip to content

Dropdown clears values on page refresh or tab switch when options are changed #2072

Open
@brianleslie

Description

@brianleslie

Describe your context

python 3.10

dash                      2.4.1 **2.3.1 does not show issue**                                                                                        
dash-bootstrap-components 1.1.0                                                                                         
dash-core-components      2.0.0                                                                                         
dash-daq                  0.5.0                                                                                         
dash-html-components      2.0.0                                                                                         
dash-table                5.0.0 

Describe the bug

Dash dcc dropdown persistence clearing all values when updating options even if returning no_update on value of dropdown

Expected behavior

dash multi selection dropdown should keep values that are still available if options are changed.

I want the inputs to be kept if a tab is changed to and back or on a page refresh (therefore i'm using persistence type local)

another page determines what dropdown options are available on original page

Screenshots

example dropdown setup

layout with a dropdown

            dcc.Dropdown(
                id='my-dropdown',
                options=[],
                value=None,
                persistence=True,
                persistence_type="local",
                multi=True
            ),
@app.callback(
    [Output("my-dropdown", "options"),
     Output("my-dropdown", "value")],
    Input("url", "pathname"),
    [State("my-dropdown", "value")]
)
def load_dropdown(pathname, dropdown_values):
   # some code here that determine what the dropdown options should be and if needed clear options that are no longer available

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions