0

As the title suggests, I'm trying to trigger an event to occur when I maximize/un-collapse a box(). The code below doesn't work (Error in : shinyjs: Invalid shiny tags given to hidden) but it's more or less what I'm trying to do.

The box object is a bs4Dash::box.

How do I accomplish this?

library(shiny)
library(shinyjs)

ui <- fluidPage(
  useShinyjs(),
  bs4Dash::box(id = "myBox", "This is my box")
)

server <- function(input, output) {
  observe({
    if (shinyjs::hidden("myBox")) {
      # do something when the box is collapsed
      print("Box is collapsed!")
    }
  })
}

shinyApp(ui, server)
R Greg Stacey
  • 425
  • 4
  • 15
  • 1
    Answer [here](https://stackoverflow.com/questions/45462614/how-to-see-if-a-shiny-dashboard-box-is-collapsed-from-the-server-side) might be helpful. – YBS Mar 20 '23 at 23:24
  • @YBS Unfortunately that solution isn't working for me. The `input$iscollapsebox1` object remains NULL, making me think the JS code part of the solution is failing for some reason. When I have time, I'll edit my question to include that attempt. – R Greg Stacey Mar 21 '23 at 18:09
  • Apologies @YBS. I wasn't aware I was using a bs4Dash box. I've edited the question to reflect that. – R Greg Stacey Mar 21 '23 at 21:17

0 Answers0