current version of absolutePanel in `rc-1.7.2` conflicts with shinyjs::hidden
gitdemont opened this issue · 5 comments
System details
Browser Version:
Output of sessionInfo()
:
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shinyjs_2.1.0 shiny_1.7.1.9003
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 digest_0.6.29 later_1.3.0 mime_0.12 R6_2.5.1 jsonlite_1.8.0 lifecycle_1.0.1 xtable_1.8-4 magrittr_2.0.3
[10] cachem_1.0.6 rlang_1.0.4 cli_3.2.0 rstudioapi_0.13 promises_1.2.0.1 jquerylib_0.1.4 bslib_0.3.1 ellipsis_0.3.2 tools_4.1.3
[19] httpuv_1.6.5 fastmap_1.1.0 compiler_4.1.3 htmltools_0.5.2 sass_0.4.1
Example application or steps to reproduce the problem
### error
library(shiny)
library(shinyjs)
app1 <- shinyApp(
ui = fluidPage(
shinyjs::useShinyjs(),
numericInput("n", "n", 1),
actionButton(inputId = "toggle_panel", label = "show/hide plot"),
shinyjs::hidden(absolutePanel(id = "test_panel",
width = "500px", height = "500px",
draggable = TRUE, top = 150, left = 0, right = 0, bottom = 0,
plotOutput("plot")))
),
server = function(input, output) {
observeEvent(eventExpr = input$toggle_panel,
ignoreInit = FALSE,
ignoreNULL = TRUE,
handlerExpr = shinyjs::toggleElement(id = "test_panel", condition = input$toggle_panel %% 2)
)
output$plot <- renderPlot(plot(head(cars, input$n)))
}
)
runApp(app1) # will not be possible since app1 is not created due to hidden error
### no error
library(shiny)
library(shinyjs)
app2 <- shinyApp(
ui = fluidPage(
shinyjs::useShinyjs(),
numericInput("n", "n", 1),
actionButton(inputId = "toggle_panel", label = "show/hide plot"),
(absolutePanel(id = "test_panel",
width = "500px", height = "500px",
draggable = TRUE, top = 150, left = 0, right = 0, bottom = 0,
plotOutput("plot")))
),
server = function(input, output) {
observeEvent(eventExpr = input$toggle_panel,
ignoreInit = FALSE,
ignoreNULL = TRUE,
handlerExpr = shinyjs::toggleElement(id = "test_panel", condition = input$toggle_panel %% 2)
)
output$plot <- renderPlot(plot(head(cars, input$n)))
}
)
runApp(app2)
Describe the problem in detail
shinyjs::hidden applied to shiny::absolutePanel generates an error with current shiny rc-v1.7.2
current CRAN release of shiny 1.7.1
does not lead to such error however
As tracked by @dvg-p4 in #3561 (comment), it seems that it comes from a9255e6
This is due to a bug in shinyjs::hidden()
. I filed an issue here daattali/shinyjs#252
@gitdemont in the meantime you could use:
absolutePanel(style = "display:none;",
id = "test_panel",
width = "500px", height = "500px",
draggable = TRUE, top = 150, left = 0, right = 0, bottom = 0,
plotOutput("plot"))
instead of shinyjs::hidden()
.
Thanks @ismirsehregal
This was only a toy example to show the issue however as I mentionned originally #3561 (comment) this would require to apply changes to already existing codes in apps and packages using hidden when it previously ran
@gitdemont I think your best bet is gonna be to thumbs-up cpsievert's pull request to fix this on the shinyjs side: daattali/shinyjs#253
Hopefully they merge that into a shinyjs release by the time you need to update to shiny 1.7.2 :-)
This will get fixed very soon in shinyjs, thanks for finding