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

updateRadioButtons() doesn't fails when length(selected) > 1 #3064

Open
ColinFay opened this issue Sep 18, 2020 · 0 comments
Open

updateRadioButtons() doesn't fails when length(selected) > 1 #3064

ColinFay opened this issue Sep 18, 2020 · 0 comments

Comments

@ColinFay
Copy link
Contributor

ColinFay commented Sep 18, 2020

When trying to send multiple values as selected in updateRadioButtons(), {shiny} doesn't throw an error, as opposed to radioButtons() alone:

Error:

library(shiny)
ui <- fluidPage(
  radioButtons("radio", "Radios", letters, selected = letters[10:11]),
  actionButton("changes", "Changes")
)

server <- function(
  input, 
  output, 
  session
){
  observeEvent(input$changes, {
    updateRadioButtons(session, "radio", selected = letters[2])
  })
}

shinyApp(ui, server)

Listening on http://127.0.0.1:7085
Warning: Error in radioButtons: The 'selected' argument must be of length 1
  79: stop
  78: radioButtons
  70: ui [#2]

With updateRadioButtons(), no error:

library(shiny)
ui <- fluidPage(
  radioButtons("radio", "Radios", letters, selected = letters[10]),
  actionButton("changes", "Changes")
)

server <- function(
  input, 
  output, 
  session
){
  observeEvent(input$changes, {
    updateRadioButtons(session, "radio", selected = letters[2:3])
  })
}

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

Successfully merging a pull request may close this issue.

1 participant