rstudio / bslib

Tools for theming Shiny and R Markdown via Bootstrap 3, 4, or 5.
https://rstudio.github.io/bslib/
Other
490 stars 58 forks source link

Footer in navsets are not shown #1136

Closed DavZim closed 5 days ago

DavZim commented 1 week ago

Describe the problem

I want to have a footer in a navset_card_x. I can do this by either using footer = ... or by using card_footer() directly, but the former is the "correct" option as far as I understand it.

When I use footer = "test", no footer is shown, when I use card_footer("test"), the footer is shown correctly, but I get a warning.

Warning message:
Navigation containers expect a collection of `bslib::nav_panel()`/`shiny::tabPanel()`s and/or `bslib::nav_menu()`/`shiny::navbarMenu()`s. Consider using `header` or `footer` if you wish to place content above (or below) every panel's contents. 

I would expect that the option footer = "test" works.

MWE

# remotes::install_github("rstudio/bslib")
packageVersion("bslib")
#> [1] ‘0.8.0’

ui <- bslib::page_fillable(
  bslib::layout_column_wrap(
    width = 1 / 2,

    # usage of footer = "test"
    bslib::navset_card_underline(
      title = "Tester",
      footer = "Footer", # Error, footer not shown
      bslib::nav_panel("A", "A"),
      bslib::nav_panel("B", "B")
    ),

    # usage of card_footer
    bslib::navset_card_underline(
      title = "Tester 2",
      bslib::nav_panel("C", "C"),
      bslib::nav_panel("D", "D"),
      bslib::card_footer("Footer") # Warning here
    )
  )
)

server <- function(input, output, session) { }

shiny::shinyApp(ui, server)

which results in this app, where the left side corresponds to footer = "test" (not working) and the right hand side corresponds to card_footer("test"), which throws the warning as mentioned above.

image

gadenbuie commented 1 week ago

This was recently fixed and will be in the next release of bslib. If you can use the development version of bslib from GitHub or https://rstudio.r-universe.dev, then this works without errors or warnings:

bslib::navset_card_underline(
  title = "Tester 2",
  bslib::nav_panel("C", "C"),
  bslib::nav_panel("D", "D"),
  footer = bslib::card_footer("Footer!")
)

Edit: big thanks as always for the awesome reprex! 👏

DavZim commented 5 days ago

Lovely, that works as expected. I tried the github dev version, which didnt work (I must have picked the wrong branch or so). But the r-universe version works.

For anyone that tries my code above and stumbles into the same problem: footer = "Footer" has the wrong format, it should be footer = bslib::card_footer("Footer")!