Skip to content

Commit

Permalink
Properly restore multi-select inputs and checkbox groups with no defa…
Browse files Browse the repository at this point in the history
…ult value when only one item is selected (fixes #5 and #8
  • Loading branch information
aoles committed Aug 8, 2016
1 parent 1928454 commit ac5b683
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: shinyURL
Type: Package
Title: Save and restore the state of Shiny apps
Version: 0.0.34
Version: 0.0.35
Encoding: UTF-8
Author: Andrzej Oleś
Maintainer: Andrzej Oleś <[email protected]>
Expand Down
6 changes: 4 additions & 2 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ shinyURL.server = function(session, options) {

q = if (is.list(q)) {
## checkbox group or multiple select
unname(q)
unlist(q, use.names=FALSE)
}
else {
## decode range vectors (sliders and dates)
Expand All @@ -92,6 +92,8 @@ shinyURL.server = function(session, options) {
if (cl=="integer")
cl = "numeric"
switch(cl,
## selectInput without default value is initially set to NULL
NULL = q,
## Dates need to be handled separately
Date = format(as.Date(as.numeric(q), "1970-01-01"), "%Y-%m-%d"),
## default case; should allow to correctly decode TRUE/FALSE
Expand Down Expand Up @@ -123,7 +125,7 @@ shinyURL.server = function(session, options) {
if (length(inputValues)==0) return()

## remove actionButtons
isActionButton = unlist(lapply(inputValues, function(x) inherits(x, "shinyActionButtonValue")), use.names=FALSE)
isActionButton = unlist(lapply(inputValues, inherits, "shinyActionButtonValue"), use.names=FALSE)
inputValues = inputValues[!isActionButton]

## remove ggvis specific inputs
Expand Down
2 changes: 1 addition & 1 deletion inst/examples/widgets/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ shinyUI(fluidPage(
)),

column(4, wellPanel(
selectInput("multiselect", label = h3("Multiple select"), choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3), selected = 1, multiple = TRUE)
selectInput("multiselect", label = h3("Multiple select"), choices = list("Choice A" = "a", "Choice B" = "b", "Choice C" = "c"), multiple = TRUE)
)),

column(4, wellPanel(
Expand Down

0 comments on commit ac5b683

Please sign in to comment.