dreamRs/shinyWidgets

Not possible to clear the airdatepicker

Closed this issue · 2 comments

Hello,
I like the airdatepicker very much, but it seems impossible to clear the picker. I have found some answers but nothing works.

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  titlePanel("Updating an airDatepicker"),
  sidebarLayout(
    sidebarPanel(
      # Setting the initially disabled
      airDatepickerInput("date_picker", "Date", 
        value = "2021-03-24"),
      actionButton("button", label = "Clear picker")   
    ),
    mainPanel(
      textOutput("text")
    )
  )
)

server <- function(input, output, session) {
  output$text <- renderText({
    input$date_picker
    input$date_picker_button
    toString(isolate(input$date_picker))
  })
  # Update the picker
  observeEvent(input$button, {
    print("clicking button")
    updateAirDateInput(session, "date_picker", 
      value = character(0)
      # value = c()
      # value = NULL
      # value = NA
      # value = as.Date(NA)
    )
  })
}
shinyApp(ui = ui, server = server)

I have tried several solutions but nothing works.
has anyone an idea?

Hi,
You can clear airDatepickerInput using clear = TRUE in updateAirDateInput, e.g. :

updateAirDateInput(session, "date_picker", clear = TRUE)

Victor

Ah, ok
thank you