Skip to content

Commit c34291a

Browse files
committed
fix: show AppBar when Tabs are the only children
1 parent 2f3514a commit c34291a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

solara/components/applayout.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,39 +257,39 @@ def AppLayout(
257257
use_drawer = True
258258
title = t.use_title_get() or title
259259
children_appbartitle = apptitle_portal.use_portal()
260-
show_app_bar = (title and (len(routes) > 1 and navigation)) or children_appbar or use_drawer or children_appbartitle
261-
262-
if style is None:
263-
style = {"height": "100%", "max-height": "100%", "overflow": "auto"}
264-
# if style is None, we choose a default style based on whether we are seeing the appbar, etc
265-
if show_app_bar or children_sidebar or len(children) != 1:
266-
style["padding"] = "12px"
267260

268261
def set_path(index):
269262
path = paths[index]
270263
location.pathname = path
271264

272265
v_slots = []
273-
266+
# Separate tabs from the other children. We want to keep a reference to any tabs that were added through children
267+
# so we can make sure AppBar is rendered even when tabs are the only children
274268
tabs = None
275269
for child_appbar in children_appbar.copy():
276270
if child_appbar.component == solara.lab.Tabs:
277271
if tabs is not None:
278272
raise ValueError("Only one Tabs component is allowed in the AppBar")
279273
tabs = child_appbar
280274
children_appbar.remove(tabs)
275+
tabs_to_render = tabs
276+
277+
show_app_bar = (title and (len(routes) > 1 and navigation)) or bool(children_appbar) or bool(use_drawer) or bool(children_appbartitle) or bool(tabs)
281278

282-
if (tabs is None) and routes and navigation and (len(routes) > 1):
283-
with solara.lab.Tabs(value=index, on_value=set_path, align="center") as tabs:
279+
if style is None:
280+
style = {"height": "100%", "max-height": "100%", "overflow": "auto"}
281+
# if style is None, we choose a default style based on whether we are seeing the appbar, etc
282+
if show_app_bar or children_sidebar or len(children) != 1:
283+
style["padding"] = "12px"
284+
285+
if (tabs_to_render is None) and routes and navigation and (len(routes) > 1):
286+
with solara.lab.Tabs(value=index, on_value=set_path, align="center") as tabs_to_render:
284287
for route in routes:
285288
name = route.path if route.path != "/" else "Home"
286289
solara.lab.Tab(name)
287-
# with v.Tabs(v_model=index, on_v_model=set_path, centered=True) as tabs:
288-
# for route in routes:
289-
# name = route.path if route.path != "/" else "Home"
290-
# v.Tab(children=[name])
291-
if tabs is not None:
292-
v_slots = [{"name": "extension", "children": tabs}]
290+
291+
if tabs_to_render is not None and navigation:
292+
v_slots = [{"name": "extension", "children": tabs_to_render}]
293293
if embedded_mode and not fullscreen:
294294
# this version doesn't need to run fullscreen
295295
# also ideal in jupyter notebooks

0 commit comments

Comments
 (0)