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

Why updateDateInput() nor dateRangeInput() don't have the datesdisabled parameter enabled? #3980

Open
laresbernardo opened this issue Feb 8, 2024 · 1 comment

Comments

@laresbernardo
Copy link

Hi!

Is there a reason why updateDateInput() doesn't have the datesdisabled parameter enabled?

Similarly, why dateRangeInput() doesn't have the datesdisabled parameter enabled?

These 2 options would be amazingly useful to a use case I'm working on.

I'm currently using shiny 1.8.0 (latest stable version).

Thanks!

@laresbernardo
Copy link
Author

laresbernardo commented Feb 8, 2024

Btw, I can share a workaround that worked for me but is less ideal than having the parameter enabled:

uiOutput("date_range_start_output"),
uiOutput("date_range_end_output")
# Within an observe() that overwrites reactiveValues from rv
  dates <- "VECTOR WITH DATES"
  start_date <- as.Date(min(dates, na.rm = TRUE), "%Y-%m-%d")
  end_date <- as.Date(max(dates, na.rm = TRUE), "%Y-%m-%d")
  rv$datesdisabled <- as.Date(start_date:end_date)[!as.Date(start_date:end_date) %in% as.Date(dates)]
  if (length(rv$datesdisabled) == 0) rv$datesdisabled <- NULL
  updateDateInput(session, "date_range_start", value = start_date, min = start_date, max = end_date)
  updateDateInput(session, "date_range_end", value = end_date, min = start_date, max = end_date)

# Update datesdisabled
output$date_range_start_output <- renderUI({
    dateInput("date_range_start", "First date:", width = "100%", datesdisabled = rv$datesdisabled)  
  })
output$date_range_end_output <- renderUI({
    dateInput("date_range_end", "Last date:", width = "100%", datesdisabled = rv$datesdisabled)  
  })

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

1 participant