Hello. I'm having an issue with dateInput and updateDateInput in shiny.
I have to update the "End Date" based on the date inserted in "Start Date". The strange thing to me is that if i use "Sys.Date() - 1" as minimum value in the start date input, the update works almost well (it just don't show de default value, even that i had specify it in the updateDateInput).
But when i use only "Sys.Date()" as minimum value in the Start Date input, the End Date input do not update and not even works (the calendar box do not open).
The updateDateInput will be working because the minimum value in "Start Date" input is set as Sys.Date() - 1. If i let just Sys.Date(), the updateDateInput do not work anymore.
Reprex:
library(shiny)
ui <- fluidPage(
titlePanel("Doubt App"),
sidebarLayout(
sidebarPanel(
dateInput("start_date",
label = HTML("Start Date"," ",as.character(actionLink(inputId = "info2",
label = "",
icon = icon("info")))),
#min = Sys.Date() # This do not work
min = Sys.Date()-1 # This work
, max = Sys.Date()+30,
format = "dd/mm/yy",
startview = 'day', weekstart = 1),
dateInput("end_date",
label = HTML("End Date"," ",as.character(actionLink(inputId = "info3",
label = "",
icon = icon("info")))),
format = "dd/mm/yy",
startview = 'day', weekstart = 1)
),
mainPanel(
tabPanel("Output", DT::dataTableOutput("mytable"))
)
)
)
server <- function(input, output,session) {
observeEvent(input$start_date,{
updateDateInput(session,"end_date",
value = Sys.Date()+120,
min = Sys.Date()+120,
max = Sys.Date()+210
)
})
output$mytable <- DT::renderDataTable({DT::datatable(
as.data.frame(cbind(format(input$start_date,"%d/%m/%Y"),
format(input$end_date,"%d/%m/%Y"))),
options = list(pageLength = 200))})
}
shinyApp(ui = ui, server = server)