Closed gregleleu closed 2 years ago
I honestly don't remember why I used singleton
and my Shiny skills are very rusty. I'd be open to a PR that removes it.
For sanity check could you please share a minimal reproducible example?
Reprex below
library(shiny)
library(rintrojs)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Reprex"),
fluidRow(
column(12,
checkboxInput("check_show", "Show UI?", value = FALSE)
)
),
fluidRow(
column(12,
uiOutput("ui_out")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$ui_out <- renderUI({
if (input$check_show) {
tagList(
p("Always rendered (not wrapped in introBox)"),
introBox(
p("Rendered only the first time"),
data.step = 1,
data.intro = "Hello"
),
div(
p("Rendered because of a workaround"),
`data-step` = 1,
`data-intro` = "Hello"
)
)
} else {
p("click on checkbox to show")
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
Removing the shiny::singleton wrapper in introBox works on my example. Lookin at the git history you had the singleton wrapper from day 1, not sure for what purpose
Had the exact same problem. Same solution works.
My app is behind a login module: the UI is generated only when the user is logged in using renderUI. First time around everything is fine. However if a user logs out :
From reading the code, I think it's due to the shiny::singleton call, as the documentation says: Only the first appearance of the content (in document order) will be used I'm pretty sure it stops the UI elements wrapped with introBox from being created again
For the moment I'm fixing it but doing
instead of introBox()
Why the call to singleton?