-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
toggleElement
with animation makes hidden output elements render
#266
Comments
toggleElement
with animation makes hidden output elements render
That's an interesting bug you found! Have you been able to replicate this in a more simple setting, not with the rows selected from a table? I'm trying to reduce this bug to the simplest possible, to track down whether it's a bug in shinyjs or in shiny. |
I was indeed able to replicate the problem in a much simpler code: library(shiny)
ui <- fluidPage(
shinyjs::useShinyjs(),
actionButton("toggle", "toggle visibility of result"),
numericInput("num", "num", 5),
textOutput("result")
)
server <- function(input, output, session) {
output$result <- renderText({
print("rendering")
input$num
})
observeEvent(input$toggle, {
shinyjs::toggle("result", anim = TRUE)
})
}
shinyApp(ui, server) Will investigate. |
I was able to trace it down to what I would consider a bug in shiny , and I filed it rstudio/shiny#3831 There is a workaround within shinyjs, wihch is to add a callback to the animation to re-trigger the "hidden" method, but this is a bit messy and it's unclear how to handle chained events and when "shown" should be triggered. In my opinion this is more of a shiny bug because shiny does not respect the |
Description
I have used
toggleElement
withanim = TRUE
to toggle the visibility of an output element. Surprisingly, the element is still rendered even if it is hidden in the UI. I assume this behavior is wrong. The bug does no longer happen if you setanim = FALSE
.The wrong rendering only happens for the first time you trigger the hidden output element (by changing a reactive dependency). This means, triggering it further times does no longer cause any rendering.
MWE
To see the bug behavior, please run the shiny app (code below) and follow listed steps. Note that I have added a print statement within the rendering call of the second table.
print
statement is evaluated.print
statement is evaluated again, even though the table is hidden in the UI.If you set
anim = FALSE
and follow the same steps, the secondprint
statement does not appear in the console.The text was updated successfully, but these errors were encountered: