Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded shinyApp() doesn't fill container's height #379

Closed
SiSch90 opened this issue Dec 16, 2021 · 3 comments
Closed

Embedded shinyApp() doesn't fill container's height #379

SiSch90 opened this issue Dec 16, 2021 · 3 comments

Comments

@SiSch90
Copy link

SiSch90 commented Dec 16, 2021

As @cpsievert already described in another thread, upgrading from rmarkdown 2.5 to 2.6 adds an additional <p> around the <iframe>, which apparently causes the display problems of flexdashboards in shiny environment described below.

@cderv minimal example based on shiny demo app:

---
title: "Test"
output: 
  flexdashboard::flex_dashboard
runtime: shiny
---

```{r}
ui <- fluidPage(titlePanel("Hello Shiny!"),
                sidebarLayout(sidebarPanel(
                  sliderInput(
                    inputId = "bins",
                    label = "Number of bins:",
                    min = 1,
                    max = 50,
                    value = 30
                  )
                ),
                mainPanel(plotOutput(outputId = "distPlot"))))
server <- function(input, output) {
  output$distPlot <- renderPlot({
    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    hist(
      x,
      breaks = bins,
      col = "#75AADB",
      border = "white",
      xlab = "Waiting time to next eruption (in mins)",
      main = "Histogram of waiting times"
    )
  })
}
shinyApp(ui, server)

2021_12_16_07_36_56_127 0 0 1_17498_view_rmarkdown

Session Info:
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] htmlwidgets_1.5.4 compiler_4.1.0 magrittr_2.0.1 fastmap_1.1.0 htmltools_0.5.2 tools_4.1.0 flexdashboard_0.5.2
[8] yaml_2.2.1 DT_0.19 rmarkdown_2.11 knitr_1.36 jsonlite_1.7.2 xfun_0.24 digest_0.6.27
[15] rlang_0.4.11 evaluate_0.14
@cpsievert cpsievert changed the title display problems within the shiny environment Embedded shinyApp() doesn't fill container's height Dec 16, 2021
@cpsievert
Copy link
Collaborator

We'll likely provide a real fix for this, but in the meantime, you can fix it by doing:

withr::with_options(
  list(htmltools.preserve.raw = FALSE),
  rmarkdown::run("reprex.Rmd")
)

@cpsievert
Copy link
Collaborator

Closing since we've identified and fixed the core issue here rstudio/htmltools#305

The "real" fix for this issue will be to install/upgrade to a new version of htmltools (and for now you'll have to do remotes::install_github("rstudio/htmltools"))

@cderv
Copy link
Collaborator

cderv commented Dec 16, 2021

Thanks @cpsievert !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants