library(shiny)
library(shinyWidgets)
ui <- fluidPage(
checkboxGroupButtons(
inputId = "check",
choices = head(month.name),
label = "Check buttons"
),
radioGroupButtons(
inputId = "radio",
choices = head(month.name),
label = "Radio buttons",
checkIcon = list(
yes = icon("check-square"),
no = icon("square-o")
)
),
tags$b("Check"),
verbatimTextOutput(outputId = "valCheck"),
tags$b("Radio"),
verbatimTextOutput(outputId = "valRadio"),
checkboxInput(inputId = "disable", label = "Disable?", value = FALSE),
checkboxInput(inputId = "disable1", label = "Disable march?", value = FALSE),
checkboxInput(inputId = "disable2", label = "Disable february & april?", value = FALSE)
)
server <- function(input, output, session) {
output$valCheck <- renderPrint({
input$check
})
output$valRadio <- renderPrint({
input$radio
})
observeEvent(input$disable, {
updateCheckboxGroupButtons(
session = session,
inputId = "check",
disabled = input$disable
)
updateRadioGroupButtons(
session = session,
inputId = "radio",
disabled = input$disable
)
}, ignoreInit = TRUE)
observeEvent(input$disable1, {
updateCheckboxGroupButtons(
session = session,
inputId = "check",
disabledChoices = if (input$disable1) "March" else NULL
)
updateRadioGroupButtons(
session = session,
inputId = "radio",
disabledChoices = if (input$disable1) "March" else NULL
)
}, ignoreInit = TRUE)
observeEvent(input$disable2, {
updateCheckboxGroupButtons(
session = session,
inputId = "check",
disabledChoices = if (input$disable2) c("February", "April") else NULL
)
updateRadioGroupButtons(
session = session,
inputId = "radio",
disabledChoices = if (input$disable2) c("February", "April") else NULL
)
}, ignoreInit = TRUE)
}
shinyApp(ui = ui, server = server, options = list(launch.browser = TRUE))
This issue is related to #281.
When
checkIconis specified for aradioGroupButtonsdisabling the input does not function as expected. Specifically, when the input is disable, it is still possible to change the selection by clicking on the square check box next to the option name. Clicking elsewhere on a button is disabled.Example app