I am using dbc.Tabs and the tabs display fine until I update the contents on one of them. Then the tab body closes with none of the tabs selected. I can open the tab by simply selecting it again. Is there a way to make the tab selected and open after the update? Here is an extremely simplified case. To reproduce, run the app, select version2.
#!/usr/bin/env python3
"""Minimal dash program."""
from dash import callback, Dash, dcc, html, Input, Output
import dash_bootstrap_components as dbc
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = dbc.Container([dcc.Location(id='url'),
dbc.Card([dbc.CardBody([html.Div(id='page-content')])]),
dcc.Store(id='version-store', storage_type='local')])
@callback(Output('version-store', 'data'),
Input('version-dd', 'value'),
prevent_initial_call=True)
def update_store(version):
return version
@callback(Output('page-content', 'children'),
Input('url', 'pathname'),
Input('version-store', 'data'))
def render_page_content(pathname, version):
chooser = [dbc.Row([html.Div(children='version', id='view-hist-version')]),
dbc.Row([dbc.Col(dcc.Dropdown(id='version-dd',
options=['version1', 'version2'],
value='version1'),
width={'size': 2})])]
return dbc.Card([dbc.CardBody([dbc.Tabs([dbc.Tab(dbc.Card(dbc.CardBody(chooser)), label='Tab')])])])
if __name__ == '__main__':
app.run_server(debug=True)