2

I am using the airMonthpickerInput() function from the shinyWidgets package. For my particular application, the start value (month) is February 2019 (as defined in value = as.Date("2019-02-01"). This displays correctly, given the code below:

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(

             airMonthpickerInput(inputId = "select_month", label = "Select Month", value = as.Date("2019-02-01")), multiple = FALSE, autoClose = TRUE)

  )
)
)

server <- function(input, output) {


}

app<-shinyApp(ui = ui, server = server)
runApp(app, host="0.0.0.0",port=5050, launch.browser = TRUE)

However, when you try to change month, the resulting popup defaults to showing the current month (at the time of writing, January 2020). Most of the application's data is from 2019 (as you'd expect seeing as the year is now over) thus users must click the month picker, then the left arrow to show 2019's months, and then select the required month within 2019.

I would like to remove this friction (excessive button clicking) so that, when clicking the month picker, February 2019 is still highlighted (i.e. 2019 is displayed, not 2020). Is it possible to do this? I have checked the function's arguments but cannot see anything obvious that will allow me to show 2019 when trying to change the month.

Simon
  • 991
  • 8
  • 30
  • 2
    That's a bug, please open an issue : https://github.com/dreamRs/shinyWidgets – Victorp Jan 03 '20 at 15:35
  • 2
    Agree with Victorp. A point that might help others - from your question it sounds like your data is ongoing, but if all your data was in fact in 2019 you could use the `minDate` and `maxDate` arguments. – Jaccar Jan 03 '20 at 16:29
  • 2
    I'm sure that's a bug, that's my package ;p – Victorp Jan 03 '20 at 16:46
  • Not all data is in 2019, unfortunately. Now that we're in 2020, data will start rolling in for this year. I need to always display the first month with "incomplete" data (in my dataset). In this example I hardcoded the input as Feb 2019 but, in production, the month will change dynamically as more data are added to the system from last year and months get "completed/signed off". – Simon Jan 03 '20 at 17:13
  • 1
    I see two options, I explain in the issue thread – Victorp Jan 03 '20 at 17:16

1 Answers1

1

Turns out there was a bug in shinyWidgets::airiMonthinputPicker(). A very quick bug fix from @Victorp has resolved the issue. If anyone else is currently expericing this issue, reinstall shinyWidgets from Github. Full details can be found here: https://github.com/dreamRs/shinyWidgets/issues/248

Simon
  • 991
  • 8
  • 30