Hide the button when the multi-selection is empty with eventReactive

Split from How to tell a multiple selection is empty?


I have a similar issue: I have a selectInput control with multiple selection and ignoreNULL = FALSE, the only difference is that I use an eventReactive function. For some reason, eventReactive does not detect the change when the last element of the selectInput is removed.

Does anybody know why this happens? I would really appreciate any insight on this issue.

What you describe sounds like it should work.

I've included a small app below for you to try. If you're still having issues, please reply with the smallest app you can provide that still produces your situation.

Thank you,
Barret

library(shiny)

ui <- fluidPage(
  selectInput("myselect", "Label", c("A", "B", "C"), multiple = TRUE)
)
server <- function(input, output) {
  len <- eventReactive(
    input$myselect, 
    ignoreNULL = FALSE, 
    {
      length(input$myselect)
    }
  )
  observe({
    cat("Length only: ", len(), "\n", sep = "")
  })
  observe({
    cat(
      "Length: ", len(), ". ",
      "Choices: ", paste0(input$myselect, collapse = ", "), 
      "\n", 
      sep = ""
    )
  })
}
shinyApp(ui, server)