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

Make a selection box appearing only on double click #58

Closed
pythiantech opened this issue Sep 2, 2018 · 4 comments
Closed

Make a selection box appearing only on double click #58

pythiantech opened this issue Sep 2, 2018 · 4 comments

Comments

@pythiantech
Copy link

While running a shiny application, the 'make a selection' box does not appear until you double click on the icon. Thereafter if you resize it, it disappears again. I have tried this in both Firefox and Chrome.

Here's the code I am using:

library(crosstalk)
library(leaflet)
library(DT)
library(shiny)

ui <- fluidPage(
  fluidRow(
    column(6, leafletOutput('cmap',height=600, width='100%')),
    column(6, dataTableOutput('cmapTable'))
  )
)

server <- function(input, output, session) {
  sDraft <- SharedData$new(df)

  output$cmap <- renderLeaflet({
    leaflet(sDraft) %>% addTiles() %>%
      addMarkers(lng = ~lon, lat=~lat)
    })

  output$cmapTable <- renderDataTable({
    datatable(sDraft, options = list(scrollX = TRUE),filter='top')
  },server = FALSE)
}

shinyApp(ui, server)

Here's the df data:

structure(list(mmsi = c(538004533L, 538004534L, 538004536L, 538005117L, 
538005118L, 538005120L), Name = c("STI GARNET", "STI TOPAZ", 
"STI ONYX", "STI LE ROCHER", "STI FONTVIEILLE", "STI VILLE"), 
    Dwt = c(51840L, 51840L, 49990L, 49990L, 49990L, 49990L), 
    lat = c(25.0050144, 11.213192, 1.26014328, 13.41435, 32.3204, 
    5.7550416), lon = c(55.05124, 121.773193, 103.914574, -18.28864, 
    -117.113571, 81.47743)), row.names = c(NA, -6L), class = c("grouped_df", 
"tbl_df", "tbl", "data.frame"), vars = "mmsi", drop = TRUE, indices = list(
    0L, 1L, 2L, 3L, 4L, 5L), group_sizes = c(1L, 1L, 1L, 1L, 
1L, 1L), biggest_group_size = 1L, labels = structure(list(mmsi = c(538004533L, 
538004534L, 538004536L, 538005117L, 538005118L, 538005120L)), row.names = c(NA, 
-6L), class = "data.frame", vars = "mmsi", drop = TRUE))

I am on a MacBook Pro (macOS High Sierra Version 10.13.6)

@jcheng5
Copy link
Member

jcheng5 commented Sep 2, 2018

@schloerke, do you mind investigating? Seems likely to be in leaflet?

@schloerke
Copy link
Collaborator

The leaflet map when it is made without shiny works as expected.

With shiny, the map is being redrawn multiple times. When you "click" and it selects data for the first time, it glitches as if it was reset is when the map is being redrawn. This glitch only happens when something within the data is being set. (The second click would not select new data, so it would work as expected.)

I believe the shared data is not being set properly (and causing a trigger to draw the map), as shinyreactlog is trying to depend on some shared data node that doesn't exist.

Somewhere in these set of commits: https://github.com/schloerke/shiny/compare/barret/reactlog...schloerke:barret-reactlog-merge?expand=1 is a change that is causing the issue. (barret/reactlog works as expected, barret-reactlog-merge contains the latest master from shiny)

The reactlog graph looks like:
screen shot 2018-09-05 at 10 54 27 am
The bottom observe ...

crosstalk/R/crosstalk.R

Lines 249 to 256 in 1c67fbf

observe({
selection <- private$.selectionCV$get()
if (!is.null(selection) && length(selection) > 0) {
self$.updateSelection(self$key() %in% selection)
} else {
self$.updateSelection(NULL)
}
})
... is changing the upper left input value with no dependency or isolation relationship. (WEIRD!)

The reactlog graph on a working as expected branch (schloerke/shiny - barret/reactlog) looks like:
screen shot 2018-09-05 at 10 54 45 am

jcheng5 added a commit to rstudio/leaflet that referenced this issue Sep 6, 2018
schloerke pushed a commit to rstudio/leaflet that referenced this issue Sep 10, 2018
@schloerke
Copy link
Collaborator

Issue merged into rstudio/leaflet master branch.

@pythiantech Please let me know if you can still see the map resetting

devtools::install_github("rstudio/leaflet")

### example code

- Barret

@pythiantech
Copy link
Author

@schloerke @jcheng5 Thanks, working fine now!

clrpackages pushed a commit to clearlinux-pkgs/R-leaflet that referenced this issue Nov 23, 2019
… 2.0.3

leaflet 2.0.3
--------------------------------------------------------------------------------

BREAKING CHANGES
* `data("providers")` and `data("providers.details")` no longer exist. Please use `leaflet::providers` and `leaflet::providers.details`. (#636)

BUG FIXES and IMPROVEMENTS
* Integrated data from `leaflet.providers` package. See [leaflet.providers](https://rstudio.github.io/leaflet.providers/) for details. (#636)
* Fixed [rstudio/crosstalk#58](rstudio/crosstalk#58), which caused Leaflet maps that used Crosstalk shared data in Shiny apps, to be redrawn at incorrect times.
* invokeRemote() now resolves html dependencies before passing them to shiny::createWebDependency() (#620).
* Upgrade leaflet-provider to 1.4.0, enable more map variants such as CartoDB.Voyager (#567)
* `sf` objects with `names` attributes in the `st_geometry` now visualise correctly (#595)
* GeoJSON objects missing `properties` can now be displayed (#622)
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

3 participants