Skip to content

[BUG] issues with dropdown persistence in dash 3.0 #3250

@revmlx

Description

@revmlx

Describe your context
I have recently updated my dash app to dash 3.0 and noticed the persistence on my dropdowns was gone.

I have a virtual environment (python 3.10) with dash 3.

dash                      3.0.1
dash_ag_grid              31.3.1
dash-bootstrap-components 2.0.0
dash-chart-editor         0.0.1a5
dash-core-components      2.0.0
dash-defer-js-import      0.0.2
dash-extensions           1.0.20
dash-html-components      2.0.0
dash_mantine_components   1.1.0
dash-table                5.0.0
dash_uploader             0.7.0a2

I also have an older environment (python 3.11) with an older version of dash:

dash                      2.14.1
dash-ag-grid              2.4.0
dash-bootstrap-components 1.5.0
dash-core-components      2.0.0
dash-defer-js-import      0.0.2
dash-extensions           1.0.4
dash-html-components      2.0.0
dash-mantine-components   0.12.1
dash-table                5.0.0
dash-uploader             0.6.0        

Describe the bug
Initially I figured it had to do with the way I had my callbacks setup (we have many and quite complicated ones) so I grabbed the example from the site and ran it standalone:

from dash import Dash, dcc, html, Input, Output, callback

CITIES = ['Boston', 'London', 'Montreal']
NEIGHBORHOODS = {
    'Boston': ['Back Bay', 'Fenway', 'Jamaica Plain'],
    'London': ['Canary Wharf', 'Hackney', 'Kensington'],
    'Montreal': ['Le Plateau', 'Mile End', 'Rosemont']
}

app = Dash()

app.layout = html.Div([
    'Choose a city:',
    dcc.Dropdown(CITIES, 'Montreal', id='persisted-city', persistence=True),
    html.Br(),

    'correlated persistence - choose a neighborhood:',
    html.Div(dcc.Dropdown(id='neighborhood'), id='neighborhood-container'),
    html.Br(),
    html.Div(id='persisted-choices')
])


@callback(
    Output('neighborhood-container', 'children'),
    Input('persisted-city', 'value')
)
def set_neighborhood(city):
    neighborhoods = NEIGHBORHOODS[city]
    return dcc.Dropdown(neighborhoods, neighborhoods[0], id='neighborhood',
        persistence_type='session',
        persistence=city
    )


@callback(
    Output('persisted-choices', 'children'),
    Input('persisted-city', 'value'), Input('neighborhood', 'value')
)
def set_out(city, neighborhood):
    return f'You chose: {neighborhood}, {city}'


if __name__ == '__main__':
    app.run(debug=True, port=8080, host="0.0.0.0")

and persistence didn't hold.
I then tested it with the old venv (dash 2) and there it does work. Even more peculiar, if I then switch to the new venv again (dash 3), it remembers the persistent values from what I changed with dash 2. But it will not remember anything I change with dash 3.

Expected behavior

I expected to have persitsence work as it is explained in the tutorial on the website for both dash 2 and dash 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1needed for current cyclebugsomething brokenregressionthis used to work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions