View source: R/close_selects.R
| closeGlassSelect | R Documentation |
Programmatically closes one glassSelect() dropdown, one
glassMultiSelect() dropdown, or every open glasstabs select dropdown in
the current Shiny session.
closeGlassSelect(session = shiny::getDefaultReactiveDomain(), inputId)
closeGlassMultiSelect(session = shiny::getDefaultReactiveDomain(), inputId)
closeAllGlassSelects(session = shiny::getDefaultReactiveDomain())
session |
Shiny session. Defaults to the current reactive domain. |
inputId |
Input id of the widget. |
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.
No return value. Called for the side effect of closing dropdowns in the browser.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.