Skip to content

freezeReactiveValue() causes An unexpected error occurred during input validation with iv$add_rule() and updateSelectInput() #82

@asadow

Description

@asadow

The error is caused by:

  1. adding selected = character() to updateSelectInput()
  2. using choices = = character() in updateSelectInput()
ui <- fluidPage(
  selectInput("dataset", "Choose a dataset", c("pressure", "cars")),
  selectInput("column", "Choose column", character(0)),
  verbatimTextOutput("summary")
)

server <- function(input, output, session) {
  dataset <- reactive(get(input$dataset, "package:datasets"))
  
  observeEvent(input$dataset, {
    freezeReactiveValue(input, "column")
    updateSelectInput(inputId = "column", choices = names(dataset()),
                      selected = character())
  })
  
  output$summary <- renderPrint({
    summary(dataset()[[input$column]])
  })
  
  iv <- InputValidator$new()
  iv$add_rule("column", sv_optional())
  iv$enable()
  
}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions