shinyWidgets icon indicating copy to clipboard operation
shinyWidgets copied to clipboard

virtualSelectInput hides element name when only one element for one group is present

Open le-raman opened this issue 2 years ago • 2 comments

Hi devs,

Reporting following bug, with reproducible example:

library("shiny")

ui <- fluidPage(
  shiny::HTML("<br><br>"),
  shinyWidgets::virtualSelectInput(
    "test_id",
    "Label",
    list("A group" = c("An element of this group"))
  )
)

server <- function(input, output, session) {
}

shinyApp(ui, server)

Result:

image

The element name itself is thus hidden; only the group name is shown. Using two elements, the behavior is ok, and both group name and elements are shown:

image

Any ideas how to circumvent this?

Thanks!

Lennart

le-raman avatar Mar 25 '24 16:03 le-raman

Hello, If there's only one element in a group you need to use a list rather than a vector, e.g. :

list("A group" = list("An element of this group"))

pvictor avatar Mar 26 '24 10:03 pvictor

Thanks for the quick response. Can confirm that this work-around works.

le-raman avatar Mar 26 '24 10:03 le-raman