Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open a newly inserted accordion panel #872

Closed
cpsievert opened this issue Oct 27, 2023 · 2 comments · Fixed by #874
Closed

Unable to open a newly inserted accordion panel #872

cpsievert opened this issue Oct 27, 2023 · 2 comments · Fixed by #874

Comments

@cpsievert
Copy link
Collaborator

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()).

@wch
Copy link
Collaborator

wch commented Oct 28, 2023

Changing Shiny.renderContent() back to sync is problematic because it won't work with shinylive on Chrome. (More info at rstudio/shiny#3929 (comment))

I think what we can do is:

  • Change Shiny's InputBinding.receiveMessage so that it can be sync or async (similar to OutputBinding.renderValue)
  • Change all the uses of Shiny.renderContent() in bslib to use await.

Copy link

github-actions bot commented Jan 1, 2024

This issue has been automatically locked. If you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue.
🙋 Need help? Connect with us on Discord or Posit Community.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants