dreamRs / shinyWidgets

shinyWidgets : Extend widgets available in shiny
https://dreamrs.github.io/shinyWidgets/
GNU General Public License v3.0
834 stars 153 forks source link

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

Closed le-raman closed 6 months ago

le-raman commented 8 months ago

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

pvictor commented 8 months ago

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"))
le-raman commented 8 months ago

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