When using a leaflet map inside a draggable Shiny panel (e.g. absolutePanel with draggable=T), panning the leaflet map with the mouse also drags the Shiny panel.
Is there a way to prevent panning the map with the mouse from also moving the Shiny panel?
I think it is similar to this resolved issue: https://github.com/rstudio/shiny/issues/711
and there are DOM event functions related to click propagation in leaflet.
Edit:
This also occurs with Plotly plots and may be a more general issue than I initially realized. The question has been edited to include plotly.
Leaflet example:
library(leaflet)
library(shiny)
shinyApp(
ui = fluidPage(
absolutePanel(draggable=T, width='600px', wellPanel(
fluidRow(leafletOutput('map'))
))
),
server = function(input, output, session) {
output$map=renderLeaflet({
leaflet() %>%
addProviderTiles(providers$OpenStreetMap)
})
}
)
Setting the dragging option to F in leaflet resolves the problem, but makes the map less useful.
shinyApp(
ui = fluidPage(
absolutePanel(draggable=T, width='600px', wellPanel(
fluidRow(leafletOutput('map'))
))
),
server = function(input, output, session) {
output$map=renderLeaflet({
leaflet(options=leafletOptions(dragging=F)) %>%
addProviderTiles(providers$OpenStreetMap)
})
}
)
Plotly example
Zoom, pan, and select plot interactions all cause the draggable panel to move.
library(plotly)
library(shiny)
shinyApp(
ui = fluidPage(
absolutePanel(draggable=T, width='600px', wellPanel(
fluidRow(plotlyOutput('plot'))
))
),
server = function(input, output, session) {
output$plot=renderPlotly({
plot_ly(data=mtcars, type='scatter', mode='markers', x=~hp, y=~mpg, name=~cyl)
})
}
)