Repository: rstudio/shiny

Issue #1348: Feature request: Images associated with radioButton inputs
Created: 2016-09-01T18:41:05Z
Hi all,
Could something like the following be added naively to shiny? http://stackoverflow.com/questions/35783446/can-you-have-an-image-as-a-radiobutton-choice-in-shiny
I have interests in using the radioButtons() input along with .png files, where each response option is associated with a specific image. It also would have to be included naively (trying to avoid the ::: operator for CRAN packages and stability across versions). Cheers.

Duplicate issue #1140: update*Input functions should sanitize labels
Created: 2016-03-22T01:08:18Z
The update*Input functions currently pass label as raw text, and the value is assigned in the client using jQuery's .text() function. This means that if a tag object is passed, it doesn't display properly.
For example:
shinyApp(
  ui = fluidPage(
    textInput("text1", tagList("Label 1 - tagList with inline tags", tags$i("italic"))),

    textInput("text2", "Label 2 - raw HTML <i>italic</i>"),

    textInput("text3", "Label 3"),
    actionButton("updateTags", 'Update Label 3 with tagList("Label 3", tags$i("Italic"))'),
    actionButton("updateHTML", 'Update Label 3 with "Label 3 <i>italic</i>"')
  ),
  server = function(input, output, session) {
    observeEvent(input$updateTags, {
      updateTextInput(session, "text3", tagList("Label 3", tags$i("Italic")))
    })

    observeEvent(input$updateHTML, {
      updateTextInput(session, "text3", "Label 3 <i>italic</i>")
    })
  }
)
For textInputs that have a label when created:

Label 1 is created with a tagList() and tags$i() and the text displays with italics.
Label 2 tries to use raw HTML text, but the <i> tag gets escaped, so the text itself is not italic.

Label 3 is a textInput that has its label updated with updateTextInput:

When updated with tagList("Label 3", tags$i("Italic")), the result is Label 3,[object Object].
When updated with raw HTML, "Label 3 <i>italic</i>", the result is Label 3 <i>italic</i>.

The behavior should be consistent for textInput, and updateTextInput, but they treat the tagList input differently.
Additionally, for actionButton, the behavior is opposite that of updateActionButton.

actionButton respects tag objects, and escapes raw HTML, like textInput.
updateActionButton does not properly respect tag objects, and puts raw HTML inline without escaping. For example:

shinyApp(
  ui = fluidPage(
    actionButton("button1", tagList("Button 1 - tagList with inline tags", tags$i("italic"))),
    br(), br(),

    actionButton("button2", "Button 2 - raw HTML <i>italic</i>"),
    br(), br(),

    actionButton("button3", "Button"),
    br(), br(),
    actionButton("updateTags", 'Update Button 3 with tagList("Button 3", tags$i("Italic"))'),
    actionButton("updateHTML", 'Update Button 3 with "Button 3 <i>italic</i>"')
  ),
  server = function(input, output, session) {
    observeEvent(input$updateTags, {
      updateTextInput(session, "button3", tagList("Button 3", tags$i("Italic")))
    })

    observeEvent(input$updateHTML, {
      updateTextInput(session, "button3", "Button 3 <i>italic</i>")
    })
  }
)
I believe the proper solution is for the update functions to do this with the label:
label <- as.character(htmltools::as.tags(label))

Closing comment (2016-09-20T16:59:15Z): This is related to #1348.