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

Not possible to clear the airdatepicker #706

Closed
chrisoswald opened this issue Sep 13, 2024 · 2 comments
Closed

Not possible to clear the airdatepicker #706

chrisoswald opened this issue Sep 13, 2024 · 2 comments

Comments

@chrisoswald
Copy link

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?

@pvictor
Copy link
Member

pvictor commented Sep 13, 2024

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

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

Victor

@chrisoswald
Copy link
Author

Ah, ok
thank you

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

No branches or pull requests

2 participants