Skip to content

Commit 3a1f221

Browse files
committed
attempt to namespace plot source
1 parent 1fd58ea commit 3a1f221

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

R/plotly.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ plot_ly <- function(data = data.frame(), ..., type = NULL, group,
118118
id <- new_id()
119119
# avoid weird naming clashes
120120
plotlyVisDat <- data
121+
# automatically namespace source
122+
session <- shiny::getDefaultReactiveDomain()
123+
if (!is.null(session)) {
124+
source <- session$ns(source)
125+
}
121126
p <- list(
122127
visdat = setNames(list(function() plotlyVisDat), id),
123128
cur_data = id,

R/shiny.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ event_data <- function(event = c("plotly_hover", "plotly_click", "plotly_selecte
5353
stop("No reactive domain detected. This function can only be called \n",
5454
"from within a reactive shiny context.")
5555
}
56-
val <- session$input[[sprintf(".clientValue-%s-%s", event[1], source)]]
56+
src <- sprintf(".clientValue-%s-%s", event[1], session$ns(source))
57+
print(src)
58+
val <- session$input[[src]]
5759
if (is.null(val)) val else jsonlite::fromJSON(val)
5860
}

inst/htmlwidgets/plotly.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ HTMLWidgets.widget({
6262
attachKey("key");
6363
return obj;
6464
});
65-
Shiny.onInputChange(
66-
".clientValue-" + eventType + "-" + x.source,
67-
JSON.stringify(d)
68-
);
65+
var src = ".clientValue-" + eventType + "-" + x.source;
66+
Shiny.onInputChange(src, JSON.stringify(d));
6967
};
7068
};
7169

0 commit comments

Comments
 (0)