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:


ui <- function(request) {
    title = "app",
    id = "page",

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

page_ui <- function(id) {
  ns <- NS(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")

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

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

whereas I'm looking for just:

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?


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.