Skip to content

Commit 5ac456a

Browse files
authored
fix(nav_panel): Add .bslib-gap-spacing if nav panel is fillable (#1154)
1 parent 1220eaa commit 5ac456a

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
* Fixed `input_task_button` not working in a Shiny module. (#1108)
3434
* Fixed several issues with `page_navbar()` styling. (#1124)
3535
* Fixed `Renderer.output_id` to not contain the module namespace prefix, only the output id. (#1130)
36+
* Fixed gap-driven spacing between children in fillable `nav_panel()` containers. (#1152)
3637

3738
### Other changes
3839

shiny/ui/_navs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,8 +1140,9 @@ def _make_tabs_fillable(
11401140
padding=as_css_padding(padding),
11411141
__bslib_navbar_margin="0;" if navbar else None,
11421142
)
1143-
child.add_style(cast(str, styles))
11441143
child = as_fillable_container(as_fill_item(child))
1144+
child.add_style(cast(str, styles))
1145+
child.add_class("bslib-gap-spacing")
11451146

11461147
content.children[i] = child
11471148

tests/pytest/test_navs.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ def private_seed_n(n: int = 0) -> Generator[None, None, None]:
1919
yield
2020

2121

22-
def test_nav_markup():
23-
a = ui.nav_panel("a", "a")
24-
b = ui.nav_panel("b", "b")
25-
c = ui.nav_panel("c", "c")
26-
menu = ui.nav_menu(
27-
"Menu",
28-
c,
29-
"----",
30-
"Plain text",
31-
"----",
32-
ui.nav_control("Other item"),
33-
)
22+
a = ui.nav_panel("a", "a")
23+
b = ui.nav_panel("b", "b")
24+
c = ui.nav_panel("c", "c")
25+
menu = ui.nav_menu(
26+
"Menu",
27+
c,
28+
"----",
29+
"Plain text",
30+
"----",
31+
ui.nav_control("Other item"),
32+
)
33+
3434

35+
def test_navset_tab_markup():
3536
with private_seed_n():
3637
x = ui.navset_tab(a, b, ui.nav_control("Some item"), menu)
3738

@@ -65,6 +66,8 @@ def test_nav_markup():
6566
</div>"""
6667
)
6768

69+
70+
def test_navset_pill_markup():
6871
with private_seed_n():
6972
x = ui.navset_pill(menu, a, id="navset_pill_id")
7073

@@ -93,6 +96,8 @@ def test_nav_markup():
9396
</div>"""
9497
)
9598

99+
100+
def test_navset_card_pill_markup():
96101
with private_seed_n():
97102
x = ui.navset_card_pill(
98103
a,
@@ -124,15 +129,17 @@ def test_nav_markup():
124129
</div>
125130
<div class="card-body bslib-gap-spacing html-fill-item html-fill-container" style="margin-top:auto;margin-bottom:auto;flex:1 1 auto;">
126131
<div class="tab-content html-fill-item html-fill-container" data-tabsetid="7311">
127-
<div class="tab-pane html-fill-item html-fill-container" role="tabpanel" data-value="a" id="tab-7311-0" style="gap:0;padding:0;">a</div>
128-
<div class="tab-pane active html-fill-item html-fill-container" role="tabpanel" data-value="c" id="tab-7890-0" style="gap:0;padding:0;">c</div>
129-
<div class="tab-pane html-fill-item html-fill-container" role="tabpanel" data-value="b" id="tab-7311-2" style="gap:0;padding:0;">b</div>
132+
<div class="tab-pane html-fill-item html-fill-container bslib-gap-spacing" role="tabpanel" data-value="a" id="tab-7311-0" style="gap:0;padding:0;">a</div>
133+
<div class="tab-pane active html-fill-item html-fill-container bslib-gap-spacing" role="tabpanel" data-value="c" id="tab-7890-0" style="gap:0;padding:0;">c</div>
134+
<div class="tab-pane html-fill-item html-fill-container bslib-gap-spacing" role="tabpanel" data-value="b" id="tab-7311-2" style="gap:0;padding:0;">b</div>
130135
</div>
131136
</div>
132137
<script data-bslib-card-init="">window.bslib.Card.initializeAllCards();</script>
133138
</div>"""
134139
)
135140

141+
142+
def test_navset_bar_markup():
136143
with private_seed_n():
137144
x = ui.navset_bar(
138145
ui.nav_menu("Menu", "Plain text", c),
@@ -164,7 +171,7 @@ def test_nav_markup():
164171
<div class="container-fluid html-fill-item html-fill-container">
165172
Page header
166173
<div class="tab-content html-fill-item html-fill-container" data-tabsetid="7311">
167-
<div class="tab-pane active html-fill-item html-fill-container" role="tabpanel" data-value="c" id="tab-7890-1" style="--bslib-navbar-margin:0;;">c</div>
174+
<div class="tab-pane active html-fill-item html-fill-container bslib-gap-spacing" role="tabpanel" data-value="c" id="tab-7890-1" style="--bslib-navbar-margin:0;;">c</div>
168175
</div>
169176
Page footer
170177
</div>"""

0 commit comments

Comments
 (0)