library(shiny)
ui = function() fluidPage(bookmarkButton(), uiOutput("X"), uiOutput("Y"))
server = function(input, output, session) {
output$X = renderUI(selectInput("X", "select possible values of Y",
letters, multiple = TRUE))
output$Y = renderUI(selectInput("Y", "select Y", input$X, multiple = TRUE))
}
shinyApp(ui = ui, server = server, enableBookmarking = "url")
Bookmarking gets a little tricky when you have inputs that depend on other dynamically created inputs.
In this example, selectInput Y gets rendered twice on page load. The first time is when it gets initialized with its bookmarked value, but no choices since input$X doesn't exist yet. When input$X does get initialized, selectInput Y renders again with choices, but no selected value since bookmarked state only gets restored once.
The quickest way out of this mess is make X a static input instead-
library(shiny)
ui = function(request) {
fluidPage(
bookmarkButton(),
selectInput("X", "select possible values of Y", letters, multiple = TRUE),
uiOutput("Y")
)
}
server = function(input, output, session) {
output$Y = renderUI(selectInput("Y", "select Y", input$X, multiple = TRUE))
}
shinyApp(ui = ui, server = server, enableBookmarking = "url")