Copy pasting url is not returning desired tab

Hi all,

The below application is updating the url based on row selected in the DT table and the selected tab. But what happens is, when the user copy paste the url in another tab, it is not opening the specific tab, instead it is opening the default page (url : (http://127.0.0.1:XXXX/?tabs=tabs2))

library(shiny)
library(DT)

ui <- function(request) {
  shinyUI(navbarPage(
    "Title", id = "inTabset", selected = "Summary",
    tabsetPanel(id = "tabs",
                tabPanel(
                  "Readme",tags$head(tags$link(rel = "stylesheet", type="text/css", href="style.css"))
                ),
                tabPanel(
                  "Summary",
                  dataTableOutput("tab")))
  )
  )
}

server <- function(input, output, session) {
  # Make sure you only bookmark the tabsetPanel
  setBookmarkExclude(isolate(names(input)[names(input) != "tabs"]))
  
  # Every time the tab changes, store the app state as URL bookmark
  observeEvent(input$tabs, {
    session$doBookmark()
  })
  
  # Set callback that stores the app state in the URL
  onBookmarked(function(url) {
    updateQueryString(paste0("?tabs=", input$tabs), mode = "replace")
  })
  # Set callback to restore the app state from the URL
  onRestore(function(state) {
    updateTabsetPanel(inputId = "tabs", selected = getQueryString()[["tabs"]])
  })
  
  output$tab <- renderDataTable({
    datatable(iris,selection = 'single')
  })
  
  observeEvent(input$tab_rows_selected, {
    insertTab(inputId = "tabs",
              tabPanel(paste0("tabs",input$tab_rows_selected), "This a dynamically-added tab"),
              target = "Summary",select = TRUE
                
    )
  })
  

}


enableBookmarking("url")
shinyApp(ui, server)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.