Description
Describe your context
dash 2.17.1
dash_ag_grid 31.2.0
dash-bootstrap-components 1.6.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-mantine-components 0.12.1
dash-table 5.0.0
dash-testing-stub 0.0.2
Describe the bug
#2795 enabled you to pass a list of components to app.layout
. However, this does not work with page_container
.
import dash
from dash import Dash, html, page_container
app = Dash(__name__, use_pages=True, pages_folder="")
dash.register_page("/", layout=html.H1("Hello"))
app.layout = [page_container, html.H2("Stuff")]
# These work ok:
# app.layout = page_container
# app.layout = html.Div([page_container, html.H2("Stuff")])
app.run()
The first request will give the following exception:
Exception: `dash.page_container` not found in the layout
Subsequent page refreshes are ok because this check only occurs on the first request.
The problem is that the following check is failing:
Line 2257 in bbd013c
The reason for that is as follows:
assert "a" in html.Div(html.Div(id="a")) # passes
assert "a" in html.Div([html.Div(id="a")]) #passes
assert "a" in html.Div([[html.Div(id="a")]]) # FAILS - this is the relevant case here
As with #2905 probably the easiest solution is to wrap the layout in html.Div
in this case so that the check passes:
assert "a" in html.Div([html.Div([html.Div(id="a")])]) # passes
Note that while #2905 is very similar it looks like the proposed fix #2915 will not solve this case. Given these two very similar issues, maybe there's a better elsewhere that would fix both (and any other similar undiscovered issues) simultaneously?