sliderInput animate not working with renderUI R Shiny

I have a rangePicker input which dynamically sets the start and end period for a sliderInput inside of a renderUI function. When I set animate = TRUE inside the sliderInput, the play button appears, but clicking it does nothing.

When placing the sliderInput inside the UI and passing it mock start and end dates, the play button works as intended, i.e. the slider moves from the min to the max when it is clicked.

How can I get this functionality inside renderUI? Reproducible code:

library(shiny)
library(tidyverse)

dat <- data.frame(
  period = seq(from = as.POSIXct("2019-07-01 00:00:00", tz = "UTC"), to = as.POSIXct("2020-06-30 23:00:00", tz = "UTC"), by = "hour"),
  value = runif(8784, 0, 1200)
)

ui <- fluidPage(

    sidebarLayout(
        sidebarPanel(
          dateRangeInput(
            "period_picker",
            label = "Select date range",
            min = min(dat$period),
            max = max(dat$period),
            start = min(dat$period),
            end = max(dat$period),
            format = "d M yyyy"
          ),
          uiOutput(
            "range_picker"
          )
        ),

        mainPanel(
           tableOutput("showDateVal")
        )
    )
)


server <- function(input, output) {

  output$range_picker <- renderUI({
    sliderInput(
      "range_picker",
      label = "pick a range",
      min = as.POSIXct(paste0(input$period_picker[1], "00:00:00"), tz = "UTC"),
      max = as.POSIXct(paste0(input$period_picker[2], "23:00:00"), tz = "UTC"),
      timezone = "UTC",
      step = 3600,
      animate = TRUE,
      value = as.POSIXct(paste0(input$period_picker[1], "00:00:00"), tz = "UTC")
    )
  })
  
  output$showDateVal <- renderTable({
    dat %>% 
      filter(period == input$range_picker) %>%
      mutate(period = format(period,"%Y %m %d %H:%m"))
    })

}


shinyApp(ui = ui, server = server)


Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)