Skip to content

Commit

Permalink
Don't treat input/output as draggable inside of `absolutePanel(dragga…
Browse files Browse the repository at this point in the history
…ble = T)` (#3937)
  • Loading branch information
cpsievert authored Nov 1, 2023
1 parent b850cd2 commit b129739
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

* 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)

* For `InputBinding`s, the `.receiveMessage()` method can now be asynchronous or synchronous (previously it could only be synchronous). (#3930)

## Bug fixes
Expand Down
20 changes: 12 additions & 8 deletions R/jqueryui.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ absolutePanel <- function(...,

style <- paste(paste(names(cssProps), cssProps, sep = ':', collapse = ';'), ';', sep='')
divTag <- tags$div(style=style, ...)
if (isTRUE(draggable)) {
divTag <- tagAppendAttributes(divTag, class='draggable')
return(tagList(
divTag,
jqueryuiDependency(),
tags$script('$(".draggable").draggable();')
))
} else {

if (identical(draggable, FALSE)) {
return(divTag)
}

# Add Shiny inputs and htmlwidgets to 'non-draggable' elements
# Cf. https://api.jqueryui.com/draggable/#option-cancel
dragOpts <- '{cancel: ".shiny-input-container,.html-widget,input,textarea,button,select,option"}'
dragJS <- sprintf('$(".draggable").draggable(%s);', dragOpts)
tagList(
tagAppendAttributes(divTag, class='draggable'),
jqueryuiDependency(),
tags$script(HTML(dragJS))
)
}

#' @rdname absolutePanel
Expand Down

0 comments on commit b129739

Please sign in to comment.