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

htmlwidgets 1.6.3 breaks addEasyButton #891

Closed
SpeckledJim2 opened this issue Nov 24, 2023 · 1 comment
Closed

htmlwidgets 1.6.3 breaks addEasyButton #891

SpeckledJim2 opened this issue Nov 24, 2023 · 1 comment

Comments

@SpeckledJim2
Copy link

SpeckledJim2 commented Nov 24, 2023

The code below is one of the addEasyButton leaflet examples in the help file.

The code runs fine with htmlwidgets v1.6.2, but doesn't run under v1.6.3 - the easy button does not appear. The v.1.6.3 documentation refers to a potentially breaking change - reproduced below:

Potentially breaking changes

Closed #466: htmlwidgets no longer recurses into list-like objects when searching for JavaScript strings wrapped in JS(), unless the object has the class "list" or "data.frame". This stops htmlwidgets from (possibly infinitely) recursively searching objects that are not actually recursive. Widget authors who relied on the previous behavior should ensure that their widget's JS() calls are wrapped in objects that have the class "list" or "data.frame". (#467)

library(leaflet)

leaf <- leaflet() %>%
  addTiles() %>%
  addEasyButton(easyButton(
    icon = htmltools::span(class = "star", htmltools::HTML("&starf;")),
    onClick = JS("function(btn, map){ map.setZoom(1);}")))
leaf

sessionInfo() output

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/London
tzcode source: system (glibc)

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

other attached packages:
[1] leaflet_2.2.1

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.3 compiler_4.3.1    ellipsis_0.3.2    magrittr_2.0.3    fastmap_1.1.1    
 [6] R6_2.5.1          cli_3.6.1         htmltools_0.5.7   tools_4.3.1       rstudioapi_0.15.0
[11] jquerylib_0.1.4   crosstalk_1.2.1   jsonlite_1.8.7    digest_0.6.33     rlang_1.1.2  
@cpsievert
Copy link
Contributor

The latest htmlwidgets release undoes this breaking change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants