-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Code example
library(shiny)
library(shiny.fluent)
ui <- fluidPage(
shiny.fluent::DatePicker.shinyInput(
inputId = "date",
placeholder = "Select a date...",
minDate = Sys.Date() - 30 # This generates a TypeError
),
textOutput("selected_date")
)
server <- function(input, output, session) {
output$selected_date <- renderText({
paste("Selected date:", input$date)
})
}
shinyApp(ui, server)Bug description
When using DatePicker.shinyInput in the shiny.fluent package, setting the minDate property directly with Date objects in R results in an error.
Specifically, it throws a TypeError: e.getDate is not a function, indicating that the date object provided is not interpreted correctly by the underlying JavaScript component.
Here is an example code that causes this error in a Shiny app using shiny.fluent:
Expected behavior
DatePicker.shinyInput should accept minDate as an R Date object or should handle conversion to a JavaScript Date object directly.
Comments
A workaround is to explicitly convert the R date to a JavaScript Date object using htmlwidgets::JS. Here’s how this can be done:
shiny.fluent::DatePicker.shinyInput(
inputId = "date",
placeholder = "Select a date...",
minDate = htmlwidgets::JS(sprintf("new Date('%s')", as.character(Sys.Date() - 30))),
allowTextInput = TRUE
)This workaround creates the JavaScript Date object in a format compatible with Fluent UI.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels