closeGlassSelect: Close open glass select dropdowns

View source: R/close_selects.R

closeGlassSelectR Documentation

Close open glass select dropdowns

Description

Programmatically closes one glassSelect() dropdown, one glassMultiSelect() dropdown, or every open glasstabs select dropdown in the current Shiny session.

Usage

closeGlassSelect(session = shiny::getDefaultReactiveDomain(), inputId)

closeGlassMultiSelect(session = shiny::getDefaultReactiveDomain(), inputId)

closeAllGlassSelects(session = shiny::getDefaultReactiveDomain())

Arguments

session

Shiny session. Defaults to the current reactive domain.

inputId

Input id of the widget.

Details

These helpers are useful before switching tabs, opening modals, rebuilding UI, or changing layouts that can otherwise leave a dropdown visually open after its trigger moved or disappeared.

Value

No return value. Called for the side effect of closing dropdowns in the browser.

Examples

if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    useGlassTabs(),
    actionButton("close", "Close dropdowns"),
    glassSelect("region", c(North = "north", South = "south")),
    glassMultiSelect("filters", c(A = "a", B = "b"))
  )

  server <- function(input, output, session) {
    observeEvent(input$close, {
      closeAllGlassSelects(session)
    })
  }

  shinyApp(ui, server)
}


glasstabs documentation built on Sept. 11, 2026, 5:08 p.m.