Appsilon / shiny.semantic

Shiny support for powerful Fomantic UI library.
http://appsilon.github.io/shiny.semantic
Other
497 stars 96 forks source link

`multiple_radio()` with a single choice #427

Open MHaringa opened 1 year ago

MHaringa commented 1 year ago

Thanks for awesome package. It appears that multiple_radio() returns NULL in case only one choice is defined as argument. See the example below. I would expect that multiple_radio() returns "A" in the following example:

# Checkbox
library(shiny)
library(shiny.semantic)

ui <- function() {
  shinyUI(
    semanticPage(
      h1("Radioboxes"),
      multiple_radio("radioboxes", "Select Letter", LETTERS[1], selected = "A"),
      p("Selected letter:"),
      textOutput("selected_letter")
    )
  )
}

server <- shinyServer(function(input, output) {
  output$selected_letter <- renderText( input$radioboxes )
})

shinyApp(ui = ui(), server = server)

A possible work around is the following, however multiple_radio() returning "A" instead of NULL seems more obvious to me.

server <- shinyServer(function(input, output) {
  output$selected_letter <- renderText( ifelse(is.null( input$radioboxes ),
                                               "A", input$radioboxes))
})
Arlisaha commented 1 year ago

+1