Skip to content

Commit

Permalink
Merge pull request #2416 from rstudio/updateSliderInput
Browse files Browse the repository at this point in the history
getSliderType() should be able to handle NULL min/max/value, fixes #2250
  • Loading branch information
wch authored May 3, 2019
2 parents 67d3a50 + 3d6f734 commit e6c2133
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ shiny 1.3.2.9000

### Bug fixes

* Fixed [#2250](https://github.com/rstudio/shiny/issues/2250): `updateSliderInput()` now works with un-specified (or zero-length) `min`, `max`, and `value`. ([#2416](https://github.com/rstudio/shiny/pull/2416))
* Fixed [#2233](https://github.com/rstudio/shiny/issues/2233): `verbatimTextOutput()` produced wrapped text on Safari, but the text should not be wrapped. ([#2353](https://github.com/rstudio/shiny/pull/2353))


shiny 1.3.2
===========

Expand Down
4 changes: 3 additions & 1 deletion R/update-input.R
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,15 @@ updateNumericInput <- function(session, inputId, label = NULL, value = NULL,
updateSliderInput <- function(session, inputId, label = NULL, value = NULL,
min = NULL, max = NULL, step = NULL, timeFormat = NULL, timezone = NULL)
{
# If no min/max/value is provided, we won't know the
# type, and this will return an empty string
dataType <- getSliderType(min, max, value)

if (is.null(timeFormat)) {
timeFormat <- switch(dataType, date = "%F", datetime = "%F %T", number = NULL)
}

if (dataType == "date" || dataType == "datetime") {
if (isTRUE(dataType %in% c("date", "datetime"))) {
to_ms <- function(x) 1000 * as.numeric(as.POSIXct(x))
if (!is.null(min)) min <- to_ms(min)
if (!is.null(max)) max <- to_ms(max)
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,7 @@ createVarPromiseDomain <- function(env, name, value) {

getSliderType <- function(min, max, value) {
vals <- dropNulls(list(value, min, max))
if (length(vals) == 0) return("")
type <- unique(lapply(vals, function(x) {
if (inherits(x, "Date")) "date"
else if (inherits(x, "POSIXt")) "datetime"
Expand Down

0 comments on commit e6c2133

Please sign in to comment.