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

Checkboxes not captured #9

Open
vnijs opened this issue May 29, 2022 · 2 comments
Open

Checkboxes not captured #9

vnijs opened this issue May 29, 2022 · 2 comments

Comments

@vnijs
Copy link

vnijs commented May 29, 2022

capture is great! It addresses the key issue I was having with snapper yonicd/snapper#4 and shinyscreenshot daattali/shinyscreenshot#4 due to niklasvh/html2canvas#1595

Unfortunately, I did run into a couple of issues with capture. When using BS 3, checkboxes are not captured in the screenshot.

image

When using BS 4, checkboxes are not captured and text for a renderUI element is wrapped and spacing is off

image

When using BS 5, checkboxes are captured but text for the renderUI element is wrapped and spacing is off

image

Any suggestions?

cc-ing @cpsievert in case there might be a connection with bslib

Question: Any plans to send capture to CRAN?

The code used to generate the screenshots above is shown below.

library(shiny)
library(capture)
library(bslib)

viz_type <- c(
  "Distribution" = "dist", "Density" = "density", "Scatter" = "scatter",
  "Surface" = "surface", "Line" = "line", "Bar" = "bar", "Box-plot" = "box"
)

version <- 5

ui <- fluidPage(
  tags$h2(paste("Bootstrap Theme", version)),
  theme = bs_theme(version = version),
  fluidRow(
    column(
      width = 2,
      wellPanel(
        capture(
          selector = ".well",
          filename = NULL, # no download client side
          icon("camera"), "Take screenshot",
          inputId = "screenshot",
          options = list(backgroundColor = "#FFF")
        ),
        selectInput(
          inputId = "loi",
          label = "Law:",
          choices = c("normal", "uniform", "exponential")
        ),
        selectInput(
          inputId = "test",
          label = "Test-multiple:",
          choices = c("normal", "uniform", "exponential"),
          selected = c("normal", "uniform", "exponential"),
          multiple = TRUE,
          selectize = FALSE
        ),
        uiOutput("rui"),
        checkboxGroupInput(
          "cb_group",
          "Checkbox group",
          choices = c("a", "b", "c"),
          # selected = c("a", "b", "c"),
          inline = FALSE
        ),
        checkboxInput("cb_single", "Checkbox Single", value = FALSE)
      )
    ),
    column(
      width = 2,
      uiOutput("out")
    )
  )
)

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

  output$out <- renderUI({
    tags$img(src = input$screenshot)
  })

  output$rui <- renderUI({
    selectInput(
      inputId = "viz_type", label = "Plot-type:", choices = viz_type,
      selected = viz_type[1],
      multiple = FALSE
    )
  })

  distrib_r <- reactive({
    switch(
      input$loi,
      "normal" = rnorm(1000),
      "uniform" = runif(1000),
      "exponential" = rexp(1000)
    )
  })
}

shinyApp(ui, server)
@vnijs vnijs changed the title Label spacing and boostrap 3, 4, and 5 Checkboxes not captured and label wrapping with bootstrap 3, 4, and 5 (bslib) May 29, 2022
@vnijs vnijs changed the title Checkboxes not captured and label wrapping with bootstrap 3, 4, and 5 (bslib) Checkboxes not captured May 29, 2022
@vnijs
Copy link
Author

vnijs commented May 29, 2022

I just noticed: #4. This is a different issue, however. Checkboxes are not captured, even when bslib is not used at all but are captured when bootstrap5 is used with bslib.

image

library(shiny)
library(capture)

viz_type <- c(
  "Distribution" = "dist", "Density" = "density", "Scatter" = "scatter",
  "Surface" = "surface", "Line" = "line", "Bar" = "bar", "Box-plot" = "box"
)

ui <- fluidPage(
  tags$h2("Not using bslib"),
  fluidRow(
    column(
      width = 2,
      wellPanel(
        capture(
          selector = ".well",
          filename = NULL, # no download client side
          icon("camera"), "Take screenshot",
          inputId = "screenshot",
          options = list(backgroundColor = "#FFF")
        ),
        selectInput(
          inputId = "loi",
          label = "Law:",
          choices = c("normal", "uniform", "exponential")
        ),
        selectInput(
          inputId = "test",
          label = "Test-multiple:",
          choices = c("normal", "uniform", "exponential"),
          selected = c("normal", "uniform", "exponential"),
          multiple = TRUE,
          selectize = FALSE
        ),
        uiOutput("rui"),
        checkboxGroupInput(
          "cb_group",
          "Checkbox group",
          choices = c("a", "b", "c"),
          # selected = c("a", "b", "c"),
          inline = FALSE
        ),
        checkboxInput("cb_single", "Checkbox Single", value = FALSE)
      )
    ),
    column(
      width = 2,
      uiOutput("out")
    )
  )
)

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

  output$out <- renderUI({
    tags$img(src = input$screenshot)
  })

  output$rui <- renderUI({
    selectInput(
      inputId = "viz_type", label = "Plot-type:", choices = viz_type,
      selected = viz_type[1],
      multiple = FALSE
    )
  })

  distrib_r <- reactive({
    switch(
      input$loi,
      "normal" = rnorm(1000),
      "uniform" = runif(1000),
      "exponential" = rexp(1000)
    )
  })
}

shinyApp(ui, server)

@pvictor
Copy link
Member

pvictor commented Jul 4, 2022

Hi,
Yes indeed there's an issue capturing checked status for checkboxes.
There's a PR in html-to-image repo : bubkoo/html-to-image#245, but there does not seem to be any activity there...

I don't have any plan to put the package on the CRAN, for the moment it's enough here on GitHub for my use.

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

2 participants