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)
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.