bslib::bs_themer() is not compatible with inner fixedPage
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 569
- Forks
- 72
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Description
I upgraded to the latest version of bslib and can confirm that the problem persists.
Describe the problem
Using bslib::bs_themer() fails when the UI uses fixedPage() in its code.
Here is a minimal reproducible example:
ui <- fluidPage(
title = "Test",
theme = bslib::bs_theme(),
fixedPage("test")
)
server <- function(input, output) {
bslib::bs_themer()
}
shinyApp(ui, server)
And the error message:
Listening on http://127.0.0.1:5053
Browsing http://127.0.0.1:5053
Warning: Error in : `bslib::bs_themer()` requires `shiny::bootstrapLib()` to be present in the app's UI. Consider providing `bslib::bs_theme()` to the theme argument of the relevant page layout function (or, more generally, adding `bootstrapLib(bs_theme())` to the UI.
42: stop
41: bslib::bs_themer [/tmp/RtmpQ1Pvgh/R.INSTALL26981d69cd6522/bslib/R/bs-theme-preview.R#363]
40: server [#2]
3: runApp [/tmp/RtmpVRGFGf/R.INSTALL271ae265d30250/shiny/R/runapp.R#388]
2: print.shiny.appobj [/tmp/RtmpVRGFGf/R.INSTALL271ae265d30250/shiny/R/shinyapp.R#565]
1: <Anonymous>
Error : `bslib::bs_themer()` requires `shiny::bootstrapLib()` to be present in the app's UI. Consider providing `bslib::bs_theme()` to the theme argument of the relevant page layout function (or, more generally, adding `bootstrapLib(bs_theme())` to the UI.
The issue can be fixed by using bslib::page_fixed() instead of fixedPage(). However:
- The error message is misleading
bslibappears compatible with usingbslib::page_fixed()orfixedPage()interchangeably with no impact, so finding out the root of the issue is challenging
Some more tests/infos:
- The bug appears with
shiny::fixedPage()orshiny::fluidPage(). And can be fixed usingbslib::page_fixed()orbslib::page_fluid(). - The bug appears only when
fixedPage()is used internally. As you can see in my example, I'm using afluidPagein my initial call, and this one does not create the bug. It is only when used inside this function. - Using a
fixedPage()inside afluidPage()is relatively standard, typically to create a full-width header at the top of the page, and then a fixed-width container with the content of the page. Despite the misleading function naming, they don't create a page but a container, and we can have containers inside containers.
Session Info
> sessionInfo() R version 4.3.3 (2024-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 12 (bookworm)Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so; LAPACK version 3.11.0locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=fr_FR.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=Ctime zone: Europe/Paris
tzcode source: system (glibc)attached base packages:
[1] stats graphics grDevices datasets utils methods baseother attached packages:
[1] shiny_1.8.1.1
loaded via a namespace (and not attached):
[1] crayon_1.5.2 vctrs_0.6.5 cli_3.6.2 rlang_1.1.3 renv_1.0.5
[6] promises_1.3.0 jsonlite_1.8.8 xtable_1.8-4 glue_1.7.0 htmltools_0.5.8.1
[11] httpuv_1.6.15 sass_0.4.9 fansi_1.0.6 jquerylib_0.1.4 tibble_3.2.1
[16] fastmap_1.1.1 yaml_2.3.8 lifecycle_1.0.4 memoise_2.0.1 compiler_4.3.3
[21] fs_1.6.3 pkgconfig_2.0.3 Rcpp_1.0.12 later_1.3.2 digest_0.6.35
[26] R6_2.5.1 utf8_1.2.4 pillar_1.9.0 magrittr_2.0.3 bslib_0.8.0.9000
[31] tools_4.3.3 mime_0.12 cachem_1.0.8
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in R/bs-theme-preview.R around the bs_themer() check shown in the error trace, and compare how nested shiny::fixedPage() and bslib::page_fixed() contribute UI dependencies. Reproduce the minimal app, then add or update a regression test showing that bs_themer() works with an inner fixedPage() and reports the correct result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100