When uiOutput() or textOutut() are used in a fillable container but are empty, users expect that those elements are entirely invisible or completely removed. In a display: flex context, however, empty divs are still included in the allocation of space.
Notice the empty space between the two cards is almost three times larger than expected when the UI and text outputs are empty. Note that when the example app uses uiOutput("card_b", fill = TRUE), the problem is even worse.
Fixes #434
When
uiOutput()
ortextOutut()
are used in a fillable container but are empty, users expect that those elements are entirely invisible or completely removed. In adisplay: flex
context, however, empty divs are still included in the allocation of space.Example app
```r library(shiny) library(bslib) # pkgload::load_all() ui <- page_fillable( card( card_header("A"), input_switch("show_card_b", "Show card B", value = FALSE), input_switch("show_text", "Show text", value = FALSE) ), uiOutput("card_b"), textOutput("text"), card(card_header("D")) ) server <- function(input, output, session) { output$card_b <- renderUI({ req(input$show_card_b) card(card_header("B")) }) output$text <- renderText({ req(input$show_text) "This text gets regular spacing." }) } shinyApp(ui, server) ```Before
Notice the empty space between the two cards is almost three times larger than expected when the UI and text outputs are empty. Note that when the example app uses
uiOutput("card_b", fill = TRUE)
, the problem is even worse.After