Tab refresh pointing to the first tab

Hi all,

in the below app,
whenever the user is neither in tab2 or tab3 and clicks on refresh, the page is taking to tab1. Can we avoid this and make sure the page is staying in the respective tab post refreshing :slight_smile: Is it possible to achieve please guide me.

library(shiny)
ui <- fluidPage(
  tabsetPanel(
    id="inTabset",
    tabPanel("Tab 1",actionButton("switch_tab", "Go to the third tab")
    ),
    tabPanel("Tab 2", "there!"),
    tabPanel("Tab 3", "there!"))
  
)

server <- function(input, output, session) {
  
  observeEvent(input$switch_tab, {
    updateTabsetPanel(session, "inTabset",selected = "Tab 3")
  })
  
}
shinyApp(ui = ui, server = server)

I think you will need to study shiny 'Bookmark' features. such as onRestore, that will tell shiny what to do after a refresh, like bookmark every time the tab changes so when refresh happens reset the tab to the bookmark value
https://shiny.rstudio.com/reference/shiny/0.14/onBookmark.html

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

what do you mean 'refreshing' tab, do you mean when a user presses refresh / reload on their browser (outside of your shiny app). If you do then the only approach is to have bookmarked the state of the app, and register an onrestore function, to restore the bookmarked state after a refresh event occurred.

Thanks for the time.I did have a look at this link. I believe this link is telling more about bookmarking sessions. But unfortunately it is not telling about refreshing tabs. Can you tell if I am wrong please

Yeah. Ok let me try to my application