shinyStorePlus icon indicating copy to clipboard operation
shinyStorePlus copied to clipboard

Can't store values of dynamically generated inputs

Open ajlyons opened this issue 6 months ago • 9 comments

Thanks for a fantastic package. I'm trying to use shinyStorePlus in an app where most of the ui (including inputs) is dynamically generated (because it has to be recreated whenever the user picks a different language). shinyStorePlus stores the inputs that are created in the usual manner in the ui, but not dynamically generated inputs.

Is there any way to get setupStorage to save the value of dynamically created inputs? I tried setting outputs=TRUE to no avail. Other ideas welcome.

library(shiny)
library(shinyStorePlus)

ui <- fluidPage(
    initStore(),
    selectInput("sel_color", "Color (hardcoded input):", choices = c("", "green", "blue", "red", "yellow", "cyan"), selected = ""),
    uiOutput("ui_moreinputs"),
    p("Refresh the page - the value of the hard coded input is retained, but the dynamic one is not")
)

server <- function(input, output, session) {
  observe({
    output$ui_moreinputs <- renderUI(
      selectInput("sel_month", "Month (dynamically generated):", choices = c("", month.name), selected = "")
    )
  })
  
  setupStorage(appId = "shinytest03", inputs = list("sel_month", "sel_color"), session = session)
}

shinyApp(ui = ui, server = server, options = list(launch.browser = TRUE))

ajlyons avatar Aug 01 '24 07:08 ajlyons