library(shiny)
library(shinyWidgets) # 0.8.1
ui <- fluidPage(
# Select ohne Element per Group
pickerInput(inputId = "test",
label = "Picker",
choices = list("Group1" = list("A" = "A1", "B" = "B1"),
"Group2" = list("A" = "A2", "B" = "B2", "C" = "C2"),
"Group3" = list("A" = "A3", "B" = "B3", "C" = "C3")),
selected = c("A1", "B2", "C3"),
multiple = TRUE,
options = list(`max-options-group` = 1L,
title = "Select one per group",
`selected-text-format` = "count > 1",
`count-selected-text` = "{0} Groups")
),
actionButton(inputId = "update_test",
label = "Update the picker"
),
br(),
verbatimTextOutput(outputId = "res")
)
server <- function(input, output, session) {
observeEvent(input$update_test, {
updatePickerInput(session = session,
inputId = "test",
label = "Updated picker",
choices = list("Group1" = list("A" = "A1", "B" = "B1"),
"Group2" = list("A" = "A2", "B" = "B2", "C" = "C2"),
"Group3" = list("A" = "A3", "B" = "B3", "C" = "C3")),
selected = c("A1", "B2", "C3")
)
})
output$res <- renderPrint({
input$test
})
}
shinyApp(ui, server)
If I update a picker input with
updatePickerInput, I can select more than one element per group although I have previously restricted it with the option'max-options-group' = 1. Is this a bug or am I missing something?After update:
