Skip to content

Unable to open a newly inserted accordion panel  #872

@cpsievert

Description

@cpsievert

This issue was introduced by Shiny.renderContent() becoming async (in rstudio/shiny#3904).

In hindsight, it's quite obviously a bad idea for Shiny.renderContent() to always be async since, with any insert-like operation, users are going to expect that the operation to have finished before the next line of R code happens. Here's an example of that:

app.R
remotes::install_github("rstudio/shiny")

library(bslib)
library(shiny)

ui <- page_fixed(
  accordion(
    id = "acc", multiple = TRUE,
    accordion_panel("A", "a"),
    accordion_panel("B", "b")
  )
)

server <- function(input, output) {
  
  observe({
    # Triggers a Shiny.renderContent()
    accordion_panel_insert(
      "acc", accordion_panel("C", "c")
    )
    # Relies on the content being rendered
    accordion_panel_open("acc", "C")
  })
  
}

shinyApp(ui, server)

Going forward, it seems like it'd be a lot better to revert changes made to srcts/src/shiny/render.ts (except for the awaits in renderContentAsync()).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions