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

Disable radioGroupButtons with checkIcon #311

Closed
benmarchi opened this issue Aug 25, 2020 · 1 comment
Closed

Disable radioGroupButtons with checkIcon #311

benmarchi opened this issue Aug 25, 2020 · 1 comment

Comments

@benmarchi
Copy link

@benmarchi benmarchi commented Aug 25, 2020

This issue is related to #281.

When checkIcon is specified for a radioGroupButtons disabling 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

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

@pvictor
Copy link
Member

@pvictor pvictor commented Aug 27, 2020

Thanks for reporting that and for the example, it should be fixed on GitHub version.

Victor

@pvictor pvictor closed this Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.