Skip to content

pickerInput: strange behaviour with disabling individual options when some are grouped #650

@sharlagelfand

Description

@sharlagelfand

Hi! I'm running into an issue with pickerInput where disabling individual options works strangely if there are grouped options.

In the example below, the first input should have just "two" (which is in a group) disabled, and this works. The second input should have "two" (in a group) and "five" (not in a group) disabled - it does not work, only "two" is disabled. The third input should have "two" and "three" (both in a group together) disabled - this does not work, as "two", "three", and "four" are all disabled.

Not sure if I'm missing how to disable options properly, but the behaviour seems a bit odd and not consistent. Thank you - happy holidays and new year!

library(shiny)
library(shinyWidgets)

choices <- list(
  "one",
  "group" = list("two", "three"),
  "four",
  "five"
)

ui <- fluidPage(
  pickerInput(
    inputId = "p1",
    label = "only one grouped option disabled (just 'two' disabled)",
    choices = choices,
    choicesOpt = list(
      disabled = c(FALSE, TRUE, FALSE, FALSE, FALSE)
    )
  ),
  pickerInput(
    inputId = "p2",
    label = "one grouped option, one non-grouped option disabled ('two' and 'five' disabled)",
    choices = choices,
    choicesOpt = list(
      disabled = c(FALSE, TRUE, FALSE, FALSE, TRUE)
    )
  ),
  pickerInput(
    inputId = "p3",
    label = "all (and only) group options disabled ('two', 'three' disabled)",
    choices = choices,
    choicesOpt = list(
      disabled = c(FALSE, TRUE, TRUE, FALSE, FALSE)
    )
  )
)

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

shinyApp(ui = ui, server = server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions