dreamRs / shinyWidgets

shinyWidgets : Extend widgets available in shiny
https://dreamrs.github.io/shinyWidgets/
GNU General Public License v3.0
834 stars 153 forks source link

`updateAirDateInput()` does not update selected date if options is used #684

Closed stibu81 closed 7 months ago

stibu81 commented 7 months ago

This shiny app contains an airDatepickerInput and a button. If the button is clicked, the date should switch to today's date, but with shinyWidgets 0.8.3, the date does not change.

library(shiny)
library(shinyWidgets)

ui <- fluidPage(

    titlePanel("airDatepickerInput Test"),

    sidebarLayout(
        sidebarPanel(
            airDatepickerInput("date",
                        value = as.Date("2024-01-01")),
            actionButton("today", "Today")
        ),
        mainPanel()
    )
)

server <- function(input, output, session) {
  observeEvent(
    input$today,
    updateAirDateInput(
      session,
      "date",
      value = Sys.Date(),
      options = list(maxDate = as.Date("2024-03-31"))
    )
  )
}

# Run the application
shinyApp(ui = ui, server = server)

Interestingly, the option is applied correctly: the maxDate is set as expected after the button has been clicked.

With shinyWidgets 0.8.2, this works as expected. Also, when the argument options is removed, the date is updated as expected even with version 0.8.3.

Im running this on Ubuntu 22.04.4 with R 4.3.3 and shiny 1.8.1.

pvictor commented 7 months ago

Thanks for reporting this, should be fixed if you re-install from GitHub

Victor

stibu81 commented 7 months ago

Thanks for the fix. I can confirm that it now works as expected.