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

Fix updateDateRangeInput interaction from #1299 & #1315 #1317

Merged
merged 2 commits into from Aug 24, 2016

Conversation

gaborcsardi
Copy link
Contributor

@gaborcsardi gaborcsardi commented Aug 23, 2016

The logic is that NULL values are always dropped from the message, so they have no effect. NA values are kept, and will be null values in JS.

Here are two test apps.

shinyApp(
  ui = fluidPage(
    div(
      dateRangeInput("daterange", "Date range:",
                     start = "2001-01-01",
                     end   = "2010-12-31")
    ),
    actionButton("btn1", "leave start & end alone"),
    actionButton("btn11", "reset start & end with NA"),
    actionButton("btn2", "set date range start"),
    actionButton("btn3", "set date range end"),
    actionButton("btn4", "set date range start and end")
  ),
  server = function(input, output, session) {
    observeEvent(input$btn1, updateDateRangeInput(session, "daterange"))
    observeEvent(input$btn11, updateDateRangeInput(session, "daterange", start = NA, end = NA))
    observeEvent(input$btn2, updateDateRangeInput(session, "daterange", start = "2005-01-01"))    
    observeEvent(input$btn3, updateDateRangeInput(session, "daterange", end = "2006-01-01"))
    observeEvent(input$btn4, updateDateRangeInput(session, "daterange", start = "2007-01-01", end = "2008-01-01"))
  }
)
shinyApp(
  ui = fluidPage(
    div(
      dateInput("date", "Date", min = "2014-06-10"),
      dateRangeInput("daterange", "Date range:",
               start = "2001-01-01",
               end   = "2010-12-31")
    ),
    actionButton("btn1", "reset date NA"),
    actionButton("btn1", "reset date NULL"),
    actionButton("btn2", "reset date range start"),
    actionButton("btn3", "reset date range end"),
    actionButton("btn4", "reset date range start and end")
  ),
  server = function(input, output, session) {
    observeEvent(input$btn1, updateDateInput(session, "date", value = NA))
    observeEvent(input$btn1, updateDateInput(session, "date", value = NULL))
    observeEvent(input$btn2, updateDateRangeInput(session, "daterange", start = NA, end = "2005-01-01"))
    observeEvent(input$btn3, updateDateRangeInput(session, "daterange", start = "2003-01-01", end = NA))
    observeEvent(input$btn4, updateDateRangeInput(session, "daterange", start = NA, end = NA))
  }
)

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

Successfully merging this pull request may close these issues.

None yet

2 participants