Exclude inputs from other Shiny pages/modules in bookmark

Hi all! I'm trying to work out a problem re: bookmarking inputs in Shiny. Specifically, I want to bookmark only the inputs on a given page (plus the ID of the page), when each page is a different Shiny module. I know that you can use shiny::setBookmarkExclude() to exclude inputs from bookmarking, but as the documentation says:

This function can also be called from a module's server function, in which case it will exclude inputs with the specified names, from that module. It will not affect inputs from other modules or from the top level of the Shiny application.

It's not clear to me how to exclude inputs from other modules!

Here's a reprex:

library(shiny)

ui <- function(request) {
  navbarPage(
    title = "app",
    id = "page",
      page_ui("page1"),
      page_ui("page2")
  )
}

server <- function(input, output, session) {
  callModule(page_server, "page1")
  callModule(page_server, "page2")
}


page_ui <- function(id) {
  ns <- NS(id)

  tabPanel(
    id,
    selectInput(ns("select"), label = "Select", choices = letters[1:5]),
    bookmarkButton(id = ns("bookmark"))
  )
}

page_server <- function(input, output, session) {
  ns <- session$ns

  observeEvent(input$bookmark, {
    cat(names(input), "\n")
    session$doBookmark()
  })
}

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

When clicking the bookmark on the first page, this is the URL given:

http://127.0.0.1:7009/?_inputs_&page2-select=%22a%22&page=%22page1%22&page1-select=%22a%22&page1-bookmark=1&page2-bookmark=0

whereas I'm looking for just:

http://127.0.0.1:7009/?_inputs_&page=%22page1%22&page1-select=%22a%22&page1-bookmark=1

That is, only to bookmark the page selected and the inputs on it.

When the bookmark button is hit, I'm cat-ing the inputs in an attempt to see what's available, but that only seems to be the inputs inside that module (which makes sense):

select bookmark

Curious if anyone knows some creative way to name all the inputs (globally) from within a module, so I can exclude the irrelevant ones, or to only bookmark what's within the current page/module?

Thanks!!

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.