rstudio / rstudio/flexdashboard
how do i know which tab is exposed in an observeEvent()?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 848
- Forks
- 298
- PR merge metrics
- No merged PRs in 30d
Description
I need to know, within observeEvent( ... ) whether a particular tab is exposed in the interface. How do I do this? This is similar to the workaround suggested in https://github.com/rstudio/leaflet/issues/590 but with shiny, namely, by adding an "id" to the tabSetPanel(). Can I do this with flexdashboard so I can reference its state within observeEvent()???
ui <- fluidPage(
tabsetPanel(
id = "tab_being_displayed", # will set input$tab_being_displayed
tabPanel("Tab 1"),
tabPanel("Map Tab",
leafletOutput("map"),
selectInput("colors", "Color Scheme",
rownames(subset(brewer.pal.info, category %in% c("seq", "div")))
)
),
selected = "Tab 1"
)
)
server <- function(input, output, session) {
# Leaflet Output
output$map <- renderLeaflet({
leaflet(quakes) %>% addTiles() %>%
fitBounds(~min(long), ~min(lat), ~max(long), ~max(lat))
})
# leaflet Proxy
observe({
req(input$tab_being_displayed == "Map Tab") # Only display if tab is 'Map Tab'
# code here.
})
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied R tabsetPanel and observeEvent example, then review the linked Leaflet issue for the proposed tab-state workaround. Reproduce the flexdashboard case and determine whether the active tab is exposed to observeEvent; done means documenting the supported approach or confirming the limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100