shinyfullscreen icon indicating copy to clipboard operation
shinyfullscreen copied to clipboard

programmatically close fullscreen?

Open stevepowell99 opened this issue 1 year ago • 2 comments

Hi, nice package. I have some interactivity in my plots so that when user clicks on a particular element in the plot, a modal opens. When the plot is fullscreen, the modal is not visible. It would be good if I could close the fullscreen view just before opening the modal so the user can see the modal. Is there a way to do this programmatically?

stevepowell99 avatar Jul 18 '23 18:07 stevepowell99

Hello, I can't look at this right now but can you provide a small reproducible example that shows what you would like to do?

etiennebacher avatar Jul 18 '23 23:07 etiennebacher

sure

library(shiny)
library(shinyfullscreen)
library(shinyjs)

ui <- fluidPage(
  useShinyjs(),
  p("Click on the content"),
  fullscreen_this(uiOutput("plot_holder"))
)

server <- function(input, output, session) {
  
  output$plot_holder <- renderUI({
    div(id="all",
        div("some content",style="font-size:88px;"),
        p(id="clickable","Then, click on this paragraph to open a modal with more information")
    )})
  
  observe({
    onclick("clickable", showModal(modalDialog(
      div(
        p("The user needs to see this modal with more info and interact with some controls. In some configurations the modal opens behind the fullscreen and cannot be viewed. In other configurations like this one, I can successfully make the modal open in front of the fullscreen, so it is visible"),
        p("But it is still not possible to interact with the elements, eg the Interact button in this case."),
        actionButton("interact","Interact with me"),
        p("So i would like to be able to close the fullscreen when someone clicks on the button")
      )
      )
      )
      )
  })
  observeEvent(input$interact,{
    # close_fullscreen() # I wish there was such a function
    message("clicked")
  })
  
}

shinyApp(ui, server, options = list(launch.browser = TRUE))

stevepowell99 avatar Jul 19 '23 09:07 stevepowell99