posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
151 stars 16 forks source link

updateSelectInput in observeEvent not working on r-shinylive #29

Closed diogo-almeida closed 9 months ago

diogo-almeida commented 10 months ago

When trying to create a simple shinyapp with two selectInput inputs where the second one depends dynamically on the first, I notice that code that works fine with regular shiny fails when the app is exported using r-shinylive.

This behavior can be reproduced using Hadley Wickham's example from Mastering Shiny below:

library(shiny)

ui <- fluidPage(
  selectInput("dataset", "Choose a dataset", c("pressure", "cars")),
  selectInput("column", "Choose column", character(0)),
  verbatimTextOutput("summary")
)

server <- function(input, output, session) {
  dataset <- reactive(get(input$dataset, "package:datasets"))

  observeEvent(input$dataset, {
    freezeReactiveValue(input, "column")
    updateSelectInput(inputId = "column", choices = names(dataset()))
  })

  output$summary <- renderPrint({
    summary(dataset()[[input$column]])
  })
}

shinyApp(ui, server)

If the file above is app.R in folder app00/, the following does not work as intended shinylive::export("app00/", "site") httpuv::runStaticServer("site/")

while this does: shiny::runApp("app00")

Any ideas on what may be causing this?

Running the following:

packageVersion("shinylive") [1] ‘0.1.0.9000’ packageVersion("httpuv") [1] ‘1.6.11.9000’ packageVersion("shiny") [1] ‘1.7.5.1’

schloerke commented 9 months ago

Thank you for the great reprex!

However, I am able to export the app and run the exported app as expected.

Closing for now as I am able to produce expected behavior.