dreamRs / tuicalendr

:calendar: R htmlwidget for tui-calendar
https://dreamrs.github.io/tuicalendr/
Other
54 stars 3 forks source link

shiny app, calendar is skipping days when it includes dynamic input #2

Closed Psqrt closed 4 years ago

Psqrt commented 4 years ago

Hello,

I've encountered a weird behiavior from my calendar when I use it in a Shiny app with dynamic input.

Here's a reprex :

library(shiny)
library(shinyWidgets)
library(tuicalendr)
library(dplyr)

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
            pickerInput("filter_id",
                        label = "Filter",
                        selected = "id1",
                        choices = c("id1", "id2")
            )
        ),
        mainPanel(
            calendarOutput("agenda")
        )
    )
)

server <- function(input, output) {

    output$agenda <- renderCalendar({

        calendarProps <- data.frame(
            id = c("1"), 
            name = c("test"),
            color = c("#000000"), 
            bgColor = c("#fcba03"),
            borderColor = c("#fcba03")
        )

        # useless data for example
        df = data.frame("id" = c("id1", "id2"),
                        "calendarId" = rep(1, 2),
                        "title" = rep("title1", 2),
                        "start" = rep(Sys.time(), 2),
                        "end" = rep(Sys.time() + 60 * 60 * 2, 2),
                        "category" = rep("time", 2)
        )

        df = df %>% 
            filter(id == input$filter_id)

        calendar(defaultView = "week",
                 taskView = F,
                 scheduleView = "time",
                 useNav = T) %>% 
            set_calendars_props_df(calendarProps) %>% 
            add_schedule_df(df)
    })
}

shinyApp(ui = ui, server = server)

When you're in the app, select "id2" in the pickerInput then start navigating between weeks, you will notice that some days are skipped.

Thanks!

pvictor commented 4 years ago

Salut,

Thanks for reporting this and for the example 👍 , this should be fixed.

Victor

Psqrt commented 4 years ago

Salut,

Indeed, it's working fine now. Thanks for the fast answer!

pvictor commented 4 years ago

Cool! For the other question please open an issue, for now you cannot add a data.frame, but something like a for loop, but i think I can add a new function.