Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
revmlx opened this issue Mar 27, 2025 · 1 comment
Open

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

revmlx opened this issue Mar 27, 2025 · 1 comment
Labels
bug something broken P1 needed for current cycle regression this used to work

Comments

@revmlx
Copy link

revmlx commented Mar 27, 2025

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

@BSd3v
Copy link
Contributor

BSd3v commented Mar 31, 2025

Hey @revmlx,

I believe that my PR may address this: #3248

@gvwilson gvwilson added bug something broken P1 needed for current cycle labels Mar 31, 2025
@ndrezn ndrezn added the regression this used to work label Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P1 needed for current cycle regression this used to work
Projects
None yet
Development

No branches or pull requests

4 participants