dreamRs / shinyWidgets

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

virtualSelectInput(..., multiple = TRUE, showValueAsTags = TRUE, updateOn = "close") -> Removing tags does not have an effect on `input$...` #688

Open danielhoop opened 7 months ago

danielhoop commented 7 months ago

When using virtualSelectInput(..., multiple = TRUE, showValueAsTags = TRUE, updateOn = "close") and removing a single (or multiple) selected tags, input$... is not updated.

R: 4.3.3 shiny: 1.8.1.1 shinyWidgets: 0.8.4

Reproducible example

library(shiny)

#### UI ####
ui <- navbarPage(
  "Reproducible example",
  tabPanel("Example", uiOutput("uiPanelForTable"))
)

#### Panel for table ####
uiPanelForTable = quote(renderUI(tabPanel(
  "Example",
  fluidPage(
    # Sidebar layout with input and output definitions ----
    sidebarLayout(

      # Sidebar panel for inputs ----
      sidebarPanel(

        shinyWidgets::virtualSelectInput(
          inputId = "chosenValues1",
          label = "Chosen values1",
          choices = c("a", "b", "c"),
          multiple = TRUE,
          showValueAsTags = TRUE,
          updateOn = "change"
        ),

        shinyWidgets::virtualSelectInput(
          inputId = "chosenValues2",
          label = "Chosen values2 - when removing single tags, nothing happens (see output to the right)",
          choices = c("d", "e", "f"),
          multiple = TRUE,
          showValueAsTags = TRUE,
          updateOn = "close"
        )
      ),

      # Main panel for displaying outputs ----
      mainPanel(
        verbatimTextOutput("chosenValues1"),
        verbatimTextOutput("chosenValues2"),
      )
    )
  )
)))

#### Server ####
server <- function(input, output) {

  observe({
    output$chosenValues1 = renderPrint(input$chosenValues1)
    output$chosenValues2 = renderPrint(input$chosenValues2)
  })

  output$uiPanelForTable = eval(uiPanelForTable)
}

#### Run the application ####
shinyApp(ui = ui, server = server)
pvictor commented 7 months ago

It seems there's no event triggered when a tag is removed, so currently those 2 options are not compatible unfortunately.

Victor