Skip to content

Commit b129739

Browse files
authored
Don't treat input/output as draggable inside of absolutePanel(draggable = T) (#3937)
1 parent b850cd2 commit b129739

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
* Default styles for `showNotification()` were tweaked slightly to improve accessibility, sizing, and padding. (#3913)
1515

16+
* Shiny inputs and `{htmlwidgets}` are no longer treated as draggable inside of `absolutePanel()`/`fixedPanel()` with `draggable = TRUE`. As a result, interactions like zooming and panning now work as expected with widgets like `{plotly}` and `{leaflet}` when they appear in a draggable panel. (#3752, #3933)
17+
1618
* For `InputBinding`s, the `.receiveMessage()` method can now be asynchronous or synchronous (previously it could only be synchronous). (#3930)
1719

1820
## Bug fixes

R/jqueryui.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,20 @@ absolutePanel <- function(...,
7676

7777
style <- paste(paste(names(cssProps), cssProps, sep = ':', collapse = ';'), ';', sep='')
7878
divTag <- tags$div(style=style, ...)
79-
if (isTRUE(draggable)) {
80-
divTag <- tagAppendAttributes(divTag, class='draggable')
81-
return(tagList(
82-
divTag,
83-
jqueryuiDependency(),
84-
tags$script('$(".draggable").draggable();')
85-
))
86-
} else {
79+
80+
if (identical(draggable, FALSE)) {
8781
return(divTag)
8882
}
83+
84+
# Add Shiny inputs and htmlwidgets to 'non-draggable' elements
85+
# Cf. https://api.jqueryui.com/draggable/#option-cancel
86+
dragOpts <- '{cancel: ".shiny-input-container,.html-widget,input,textarea,button,select,option"}'
87+
dragJS <- sprintf('$(".draggable").draggable(%s);', dragOpts)
88+
tagList(
89+
tagAppendAttributes(divTag, class='draggable'),
90+
jqueryuiDependency(),
91+
tags$script(HTML(dragJS))
92+
)
8993
}
9094

9195
#' @rdname absolutePanel

0 commit comments

Comments
 (0)