RinteRface / shinydashboardPlus

extensions for shinydashboard
https://shinydashboardplus.rinterface.com
Other
454 stars 77 forks source link

updateBox only working once when box_id is not exactly "mybox" #96

Closed JensHeise closed 3 years ago

JensHeise commented 3 years ago

Hello!

I ran into an issue trying out the updateBox function but whatever I did, the function did only work the first time it was called. So I fiddled a bit with the functioning example from here and managed to strip this issue down to the box_id.

If you run this code it should work, but when you change the box_id to something else only the first button press works. But after that the function updateBox won't do anything and the box "freezes"...

I'm using R 4.0.3 and following package versions: shinydashboardPlus_2.0.0.9000 shinydashboard_0.7.1 shiny_1.5.0

Maybe anyone knows the cause of this issue and has an idea how to fix it?

Thank you!

Minimal example:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

box_id <- "mybox"
# box_id <- "myboxx"

ui <- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
        actionButton("update_box", "Update Box"), 
        actionButton("update_box2", "Update Box 2"),
        br(),
        br(),
        box(id = box_id, "Content")
    )
)

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

    observeEvent(input$update_box, {
        updateBox(
            box_id, 
            action = "update", 
            options = list(
                width = 12,
                background = "black"
            )
        )
    })

    observeEvent(input$update_box2, {
        updateBox(
            box_id, 
            action = "update", 
            options = list(
                width = 4,
                background = "blue"
            )
        )
    })

  }

shinyApp(ui, server)
DivadNojnarg commented 3 years ago

Maybe because you don't have the latest version of shinydashboardPlus:

remotes::install_github("RinteRface/shinydashboardPlus")