Skip to content

Commit d2257d4

Browse files
committed
take advantage of new globalScope session method
1 parent 3a1f221 commit d2257d4

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

DESCRIPTION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ Suggests:
5656
LazyData: true
5757
VignetteBuilder: knitr
5858
RoxygenNote: 5.0.1
59+
Remotes:
60+
rstudio/shiny#1344

R/plotly.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
plot_ly <- function(data = data.frame(), ..., type = NULL, group,
7878
color, colors = NULL, alpha = 1, symbol, symbols = NULL,
7979
size, sizes = c(10, 100), linetype, linetypes = NULL,
80-
width = NULL, height = NULL, source = "A") {
80+
width = NULL, height = NULL, source = "A",
81+
session = shiny::getDefaultReactiveDomain()) {
8182
if (!is.data.frame(data)) {
8283
stop("First argument, `data`, must be a data frame.", call. = FALSE)
8384
}
@@ -119,7 +120,6 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group,
119120
# avoid weird naming clashes
120121
plotlyVisDat <- data
121122
# automatically namespace source
122-
session <- shiny::getDefaultReactiveDomain()
123123
if (!is.null(session)) {
124124
source <- session$ns(source)
125125
}

R/shiny.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) {
4747
#' }
4848

4949
event_data <- function(event = c("plotly_hover", "plotly_click", "plotly_selected",
50-
"plotly_relayout"), source = "A") {
51-
session <- shiny::getDefaultReactiveDomain()
50+
"plotly_relayout"), source = "A",
51+
session = shiny::getDefaultReactiveDomain()) {
5252
if (is.null(session)) {
5353
stop("No reactive domain detected. This function can only be called \n",
5454
"from within a reactive shiny context.")
5555
}
5656
src <- sprintf(".clientValue-%s-%s", event[1], session$ns(source))
57-
print(src)
58-
val <- session$input[[src]]
57+
val <- session$rootScope()$input[[src]]
5958
if (is.null(val)) val else jsonlite::fromJSON(val)
6059
}

0 commit comments

Comments
 (0)