Skip to content

Commit b7a02e7

Browse files
authored
feat(page_main_container): Remove fill container and min-height/width when fillable=FALSE (#1188)
* fix(page_main_container): Not fill carrier when fillable=FALSE * feat(page_main): Only apply min height/width when fillable=TRUE * refactor(page_main_container): Make fill carrier or not depending on `fillable` * docs: Add news item * docs: tweak news
1 parent ee34398 commit b7a02e7

File tree

12 files changed

+25
-24
lines changed

12 files changed

+25
-24
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* `bs_theme_dependencies()` now avoids unecessarily copying internal package files to R's temporary directory more than once when preparing precompiled theme dependencies (e.g. for a standard `bs_theme()` theme). (#1184)
66

7+
* Fixed an issue where the `<main>` areas of `page_sidebar()` and `page_navbar()` (with a `sidebar`) were made to be a fillable containers even when `fillable = FALSE`. (#1188)
8+
79
# bslib 0.9.0
810

911
## Breaking changes

R/bs-theme-preset-brand.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ brand_resolve.brand_yml <- function(brand, ...) {
123123
brand_resolve_preset <- function(brand, preset = NULL, version = NULL) {
124124
version_resolved <-
125125
version %||%
126-
brand_pluck(brand, "defaults", "shiny", "theme", "version") %||%
127-
brand_pluck(brand, "defaults", "bootstrap", "version") %||%
128-
version_default()
126+
brand_pluck(brand, "defaults", "shiny", "theme", "version") %||%
127+
brand_pluck(brand, "defaults", "bootstrap", "version") %||%
128+
version_default()
129129

130130
preset_resolved <-
131131
preset %||%
132-
brand_pluck(brand, "defaults", "shiny", "theme", "preset") %||%
133-
switch_version(version_resolved, five = "shiny", default = "bootstrap")
132+
brand_pluck(brand, "defaults", "shiny", "theme", "preset") %||%
133+
switch_version(version_resolved, five = "shiny", default = "bootstrap")
134134

135135
resolve_bs_preset(preset_resolved, version = version_resolved)
136136
}

R/layout.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ layout_column_wrap <- function(
9090
if (missing(width)) {
9191
first_is_width <-
9292
is.null(children[[1]]) ||
93-
is_probably_a_css_unit(children[[1]])
93+
is_probably_a_css_unit(children[[1]])
9494

9595
if (first_is_width) {
9696
# Assume an unnamed first argument that matches our expectations for

R/navs-legacy.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ navbarPage_ <- function(
409409
fillable = !isFALSE(fillable),
410410
border_radius = FALSE,
411411
border = !fluid,
412-
page_main_container(contents)
412+
page_main_container(contents, fillable = !isFALSE(fillable))
413413
)
414414
)
415415

R/page.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ page_sidebar <- function(
281281
border = FALSE,
282282
border_radius = FALSE,
283283
!!!dots$attribs,
284-
page_main_container(dots$children)
284+
page_main_container(dots$children, fillable = fillable)
285285
)
286286

287287
page_fillable(
@@ -297,13 +297,12 @@ page_sidebar <- function(
297297
)
298298
}
299299

300-
page_main_container <- function(...) {
301-
as_fill_carrier(
302-
tags$main(
303-
class = "bslib-page-main bslib-gap-spacing",
304-
...
305-
)
300+
page_main_container <- function(..., fillable = TRUE) {
301+
main <- tags$main(
302+
class = "bslib-page-main bslib-gap-spacing",
303+
...
306304
)
305+
if (fillable) as_fill_carrier(main) else main
307306
}
308307

309308
maybe_page_sidebar <- function(x) {
@@ -414,7 +413,7 @@ page_navbar <- function(
414413
# TODO: Coordinate with next bslib version bump in Shiny to use the new interface
415414
was_called_by_shiny <-
416415
isNamespaceLoaded("shiny") &&
417-
identical(rlang::caller_fn(), shiny::navbarPage)
416+
identical(rlang::caller_fn(), shiny::navbarPage)
418417

419418
.navbar_options <- navbar_options_resolve_deprecated(
420419
options_user = navbar_options,

R/sysdata.rda

-127 Bytes
Binary file not shown.

inst/components/dist/components.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/components/scss/page_sidebar.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ $bslib-sidebar-padding: $spacer * 1.5 !default;
4444
// Ensure the page-level main area has a minimum height and width to prevent
4545
// overly squished content in small screens, like IDE preview panels.
4646
.bslib-sidebar-layout {
47-
.bslib-page-main {
47+
.bslib-page-main.html-fill-container {
4848
min-height: var(--bslib-page-main-min-height, #{$bslib-page-main-min-height});
4949
}
5050

5151
// But only apply the width constraint when the sidebar expanded (i.e.
5252
// not collapsed or in transition) to prevent overlap with toggle button.
5353
&:not(.sidebar-collapsed),
5454
&.transitioning {
55-
.bslib-page-main {
55+
.bslib-page-main.html-fill-container {
5656
min-width: var(--bslib-page-main-min-width, #{$bslib-page-main-min-width});
5757
}
5858
}

inst/examples-shiny/brand.yml/app.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (requireNamespace("thematic", quietly = TRUE)) {
4646

4747
is_app_hosted <-
4848
Sys.getenv("R_CONFIG_ACTIVE") %in%
49-
c("shinylive", "shinyapps", "rsconnect", "rstudio_cloud")
49+
c("shinylive", "shinyapps", "rsconnect", "rstudio_cloud")
5050
is_app_packaged <-
5151
getwd() != system.file("examples-shiny/brand.yml", package = "bslib")
5252

inst/examples-shiny/build-a-box/R/random_plot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ random_plotly_plot <- function(type = NULL, color = "white") {
5454

5555
random_plotly_bar <- function(color, n = 50) {
5656
plot_ly(
57-
x = ~runif(n),
57+
x = ~ runif(n),
5858
type = "histogram",
5959
histnorm = "probability",
6060
nbinsx = 10,
@@ -66,7 +66,7 @@ random_plotly_bar <- function(color, n = 50) {
6666
}
6767

6868
random_plotly_box <- function(color, n = 50) {
69-
plot_ly(x = ~rnorm(n), type = "box", color = I(color))
69+
plot_ly(x = ~ rnorm(n), type = "box", color = I(color))
7070
}
7171

7272
random_plotly_line <- function(color, n) {

0 commit comments

Comments
 (0)