I've come across an issue where clicking the "X" at the end of a dateInput
field clears the field itself, but does not record the input
value as a blank or NA.
Take this example:
library(shiny)
ui <- fluidPage(
headerPanel("Example"),
mainPanel(
# input field
dateInput("user_text", label = "Date:", value = NA),
# display text output
textOutput("text"))
)
server <- function(input, output) {
# reactive expression
text_reactive <- reactive({
format(input$user_text)
})
observe({
print(format(input$user_text))
})
# text output
output$text <- renderText({
text_reactive()
})
}
shinyApp(ui = ui, server = server)
Selecting a date prints the date to output$text
and the console. Highlighting the date and pressing delete or backspace on the keyboard correctly clears the value from the cell and records "" as the value for output$text
. Instead of using backspace or delete to clear the value, click the "X" at at the end of the dateInput
field. This correctly clears the field itself, but leaves the last selected date as the value for output$text
.
Is this a bug or is there a way to make clicking the "X" set the value of output$text
to ""?