From d8671c395c3d6c0880b329a6d44703fba7455b38 Mon Sep 17 00:00:00 2001 From: Barbara Borges Ribeiro Date: Wed, 22 Mar 2017 02:31:57 +0000 Subject: [PATCH] news item and comment --- NEWS.md | 2 ++ R/input-utils.R | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4814ffe9b6..26fc92d021 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ shiny 1.0.0.9001 ### Minor new features and improvements +* Addressed [#1348](https://github.com/rstudio/shiny/issues/1348) and [#1437](https://github.com/rstudio/shiny/issues/1437) by adding two new arguments to `radioButtons()` and `checkboxGroupInput()`: `choiceNames` (list or vector) and `choiceValues` (list or vector). These can be passed in as an alternative to `choices`, with the added benefit that the elements in `choiceNames` can be arbitrary UI (i.e. anything created by `HTML()` and the `tags()` functions, like icons and images). While the underlying values for each choice (passed in through `choiceValues`) must still be simple text, their visual representation on the app (what the user actually clicks to select a different option) can be any valid HTML element. See `?radioButtons` for a small example. [#1521](https://github.com/rstudio/shiny/pull/1521)) + * Fixed [#1565](https://github.com/rstudio/shiny/issues/1565), which meant that resources with spaces in their names return HTTP 404. ([#1566](https://github.com/rstudio/shiny/pull/1566)) * Exported `session$user` (if it exists) to the client-side; it's accessible in the Shiny object: `Shiny.user`. ([#1563](https://github.com/rstudio/shiny/pull/1563)) diff --git a/R/input-utils.R b/R/input-utils.R index 412bda1c3e..03728994eb 100644 --- a/R/input-utils.R +++ b/R/input-utils.R @@ -2,6 +2,14 @@ controlLabel <- function(controlName, label) { label %AND% tags$label(class = "control-label", `for` = controlName, label) } +# This function takes in either a list or vector for `choices` (and +# `choiceNames` and `choiceValues` are passed in as NULL) OR it takes +# in a list or vector for both `choiceNames` and `choiceValues` (and +# `choices` is passed as NULL) and returns a list of two elements: +# - `choiceNames` is a vector or list that holds the options names +# (each element can be arbitrary UI, or simple text) +# - `choiceValues` is a vector or list that holds the options values +# (each element must be simple text) normalizeChoicesArgs <- function(choices, choiceNames, choiceValues) { # if-else to check that either choices OR (choiceNames + choiceValues) # were correctly provided