daattali / shinyjs

💡 Easily improve the user experience of your Shiny apps in seconds
https://deanattali.com/shinyjs
Other
734 stars 119 forks source link

Nested show/hides don't work #243

Closed jntrcs closed 3 years ago

jntrcs commented 3 years ago

Is there a reason why nesting hidden()s inside one another does not work? When I click the action button in the following example, instead of showing the outer div on the screen, it prints "OuterDiv" to the console.

library(shiny)
library(shinyjs)
ui <- fluidPage(

   useShinyjs(),
   hidden(div(id="OuterDiv", "Outer Div",
              hidden(div(id="InnerDiv", "Inner Div")))),
   actionButton("Show", "Show Outer Div")
)
server <- function(input, output) {
    observeEvent(input$Show, {
        show("OuterDiv")
    })
}
shinyApp(ui = ui, server = server)

Output of sessioninfo


> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8   
 [6] LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C           LC_TELEPHONE=C        
[11] LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] mapapp_0.0.0.9000              sp_1.4-2                       shinyBS_0.61                  
 [4] shinyjs_2.0.0                  leaflet.extras_1.0.0           leaflet_2.0.4.1               
 [7] forcats_0.5.0                  stringr_1.4.0                  purrr_0.3.4                   
[10] readr_1.3.1                    tidyr_1.1.2                    tibble_3.1.2                  
[13] ggplot2_3.3.5                  tidyverse_1.3.0                shiny_1.7.0                   
[16] podiumr_0.7.1.0.0.0.1631656730 dplyr_1.0.7                   

loaded via a namespace (and not attached):
 [1] fs_1.5.0                lubridate_1.7.10        fontawesome_0.2.2       bit64_4.0.5            
 [5] httr_1.4.2              rprojroot_2.0.2         tools_4.1.1             backports_1.2.0        
 [9] bslib_0.3.0             utf8_1.2.1              R6_2.5.0                DT_0.16                
[13] DBI_1.1.1               colorspace_2.0-1        withr_2.4.2             tidyselect_1.1.1       
[17] prettyunits_1.1.1       processx_3.5.2          bit_4.0.4               compiler_4.1.1         
[21] cli_3.0.1               rvest_0.3.6             xml2_1.3.2              desc_1.2.0             
[25] sass_0.4.0              scales_1.1.1            callr_3.7.0             digest_0.6.27          
[29] pkgconfig_2.0.3         htmltools_0.5.2         dbplyr_1.4.4            fastmap_1.1.0          
[33] htmlwidgets_1.5.3       rlang_0.4.11            readxl_1.3.1            rstudioapi_0.13        
[37] jquerylib_0.1.4         generics_0.1.0          jsonlite_1.7.2          crosstalk_1.1.0.1      
[41] magrittr_2.0.1          Rcpp_1.0.6              munsell_0.5.0           fansi_0.5.0            
[45] shinycssloaders_1.0.0   lifecycle_1.0.0         stringi_1.6.2           yaml_2.2.1             
[49] pkgbuild_1.2.0          grid_4.1.1              blob_1.2.1              promises_1.2.0.1       
[53] crayon_1.4.1            lattice_0.20-44         haven_2.3.1             hms_1.1.0              
[57] ps_1.6.0                pillar_1.6.1            pkgload_1.1.0           reprex_0.3.0           
[61] glue_1.4.2              leaflet.providers_1.9.0 RPostgres_1.3.3         modelr_0.1.8           
[65] vctrs_0.3.8             httpuv_1.5.5            testthat_3.0.1          cellranger_1.1.0       
[69] gtable_0.3.0            assertthat_0.2.1        cachem_1.0.4            mime_0.10              
[73] xtable_1.8-4            broom_0.7.3             later_1.2.0             rsconnect_0.8.17       
[77] ellipsis_0.3.2         ```
jntrcs commented 3 years ago

Closing as it appears to be a naming conflict with one of the function names in shinyjs and other libraries