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

When using updateBox on nested boxes to change the box title, the titles of all boxes in the nesting change #388

Open
LoganSWA opened this issue Jan 20, 2025 · 0 comments

Comments

@LoganSWA
Copy link

LoganSWA commented Jan 20, 2025

I have found that if you have set of nested boxes using the bs4Dash library in R shiny, when using the updateBox function to update the title of one box (in my example, the top of the nesting hierarchy) all box titles change, despite having different box ids.

The desired outcome is for checking 'Service_1' to update the title of 'services_box' without affecting any other box.

library(shiny)
library(bs4Dash)
library(shinyWidgets)

ui <- bs4Dash::dashboardPage(
  bs4Dash::dashboardHeader(),
  bs4Dash::dashboardSidebar(disable = TRUE),
  bs4Dash::dashboardBody(
    bs4Dash::box(
      id = "services_box",
      title = "Select Services",
      width = NULL,
      solidHeader = TRUE,
      status = "warning",
      fluidRow(
        bs4Dash::box(
          title = "Group 1",
          id = "Group_1",
          width = 4,
          collapsible = FALSE,
          fluidRow(column(
            width = 6,
            shinyWidgets::prettyCheckbox(
              "service_checkbox",
              label = "Service_1",
              status = "warning",
              shape = "curve",
              animation = "smooth",
              fill = TRUE,
              icon = icon("check")
            )
          ))
        )
      ),
      
      hr(),
      bs4Dash::box(
        title = "Screening Questions",
        id = "question_box",
        width = 12,
        collapsible = FALSE,
        column(
          width = 12,
          shinyWidgets::prettyCheckbox(
            "question_checkbox",
            label = "Question 1",
            status = "success",
            shape = "curve",
            animation = "smooth",
            fill = TRUE
          )
        )
      )
    )
  )
)

server <- function(input, output, session) {
  observeEvent(input$service_checkbox, ignoreInit = TRUE, {
    bs4Dash::updateBox(
      id = "services_box",
      action = "update",
      session = session,
      options = list(title = shiny::h2("Updated Title"))
    )
  })
}

shinyApp(ui, server)
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

1 participant