juba / shinyglide

Glide.js component for Shiny apps
https://juba.github.io/shinyglide/
91 stars 8 forks source link

shinyglide Conflicts with slickR #4

Closed JonP-16 closed 5 years ago

JonP-16 commented 5 years ago

Hi!

Great package; I love the functionality. However, I think I've found a bug. It seems that whenever slickR is used, the 'glide' content of the modal gets very squished and unreadable. I'm not sure if this is your package or if it's slickR's package but I thought I should let you know.

library(shiny)
library(shinyglide)
library(slickR)

ui <- fixedPage(  
  fluidRow(
    slickROutput("slickr", width="500px")
  ) 
)

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

  showModal(
    modalDialog(
      title = "Startup assistant",
      easyClose = FALSE,
      footer = NULL,
      glide(
        screen(
          p("Let's initialize some values, would you ?")
        ),
        screen(
          p("First, please select a mean value"),
          numericInput("mean_modal", "Mean", value = 0)
        ),
        screen(
          p("Then, please select a sd value"),
          numericInput("sd_modal", "SD", value = 0)
        )
      )
    )
  )

  png('image1.png'); plot(rnorm(100)); dev.off()
  png('image2.png'); plot(runif(100)); dev.off()
  output$slickr <- renderSlickR({
    slickR(c("image1.png",
             "image2.png"),
           height='400px',width='100%')
  })
  }

shinyApp(ui, server)
juba commented 5 years ago

Thanks for the report and the reproducible example !

Indeed, I can reproduce the issue. It seems as if the presence of a slickR widget stops the initialization of shinyglide elements. The problem is solved when resizing the window for example. I'm not sure where this can come from for the moment, but I'll take a look.

juba commented 5 years ago

I think this should now be fixed in the development version. Thanks again for reporting the problem.

JonP-16 commented 5 years ago

I downloaded your latest update from Github and also installed the latest version of slickR on Cran but I think I found an extension of this same bug. It's the same problem when the modal is accessed via a link (and I suspect any other button type object):

library(shiny)
library(shinyglide)
library(slickR)

ui <- fixedPage(  
  fluidRow(
    actionLink(inputId = "glide_modal_link", label = "Click here for modal."),
    slickROutput("slickr", width="500px")
  ) 
)

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

  modal_controls <- glideControls(
    list(
      prevButton(),
      firstButton(
        class = "btn btn-danger",
        `data-dismiss`="modal",
        "No, thanks !"
      )
    ),
    list(
      nextButton(),
      lastButton(
        class = "btn btn-success",
        `data-dismiss`="modal",
        "Done"
      )
    )
  )

  observeEvent(input$glide_modal_link, {
    showModal(
      modalDialog(
        title = "Startup assistant",
        easyClose = FALSE,
        footer = NULL,
        glide(
          custom_controls = modal_controls,
          screen(
            p("Let's initialize some values, would you ?")
          ),
          screen(
            p("First, please select a mean value"),
            numericInput("mean_modal", "Mean", value = 0)
          ),
          screen(
            p("Next, please select a standard deviation value"),
            numericInput("sd_modal", "Standard deviation", value = 1, min = 0)
          ),
          screen(
            p("Thanks, we're all set !")
          )
        )
      )
    )
  })

  png('image1.png'); plot(rnorm(100)); dev.off()
  png('image2.png'); plot(runif(100)); dev.off()
  output$slickr <- renderSlickR({
    slickR(c("image1.png",
             "image2.png"),
           height='400px',width='100%')
  })
}

shinyApp(ui, server)

Thanks a bunch for looking into it and being so responsive!

juba commented 5 years ago

Well, this may now be fixed, but I'll be waiting for your confirmation before closing it, because modal handling is a bit tricky.

Thanks again for taking the time to report !

JonP-16 commented 5 years ago

Hmmm...I downloaded your package again from Github and it seems to have the same behavior. Your first fix works now so that it runs upon startup but when clicking the actionlink, I'm still getting the squished output.

If it helps, I'm on a Windows 10:

> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] slickR_0.2.4     shinyglide_0.1.1 shiny_1.3.2     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        codetools_0.2-16  digest_0.6.19     foreach_1.4.4     later_0.8.0      
 [6] mime_0.6          R6_2.4.0          jsonlite_1.6      xtable_1.8-3      magrittr_1.5     
[11] rlang_0.3.4       promises_1.0.1    doParallel_1.0.14 xml2_1.2.0        iterators_1.0.10 
[16] tools_3.5.3       htmlwidgets_1.3   httpuv_1.5.0      yaml_2.2.0        parallel_3.5.3   
[21] compiler_3.5.3    base64enc_0.1-3   htmltools_0.3.6  
juba commented 5 years ago

Ah, sorry, you're right, the code worked on a modified version of your example, but not on the original one. I'll look into it.

juba commented 5 years ago

Ok, so, I think this might be fixed now. But once again I'll wait for your confirmation before closing the issue :-)

JonP-16 commented 5 years ago

Success! Thanks for your prompt fix. Works great now.