Skip to content

Commit 4b4085f

Browse files
committed
Follow up to #1952: add crosstalk mapping to computed_mapping (not mapping) when present
1 parent 9fe33eb commit 4b4085f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

R/ggplotly.R

+6-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ gg2list <- function(p, width = NULL, height = NULL,
264264
layers <- Map(function(x, y) {
265265
if (crosstalk_key() %in% names(y) && !"key" %in% names(x[["mapping"]]) &&
266266
inherits(x[["stat"]], "StatIdentity")) {
267-
x[["mapping"]] <- c(x[["mapping"]], key = as.name(crosstalk_key()))
267+
# ggplot2 v3.3.4 started using the computed_mapping (instead of mapping)
268+
# field to inform the compute_aesthetics() method, so in order to add
269+
# the crosstalk key, we need to add to that field (when present)
270+
# https://github.com/tidyverse/ggplot2/pull/4475
271+
nm <- if ("computed_mapping" %in% names(x)) "computed_mapping" else "mapping"
272+
x[[nm]] <- c(x[[nm]], key = as.name(crosstalk_key()))
268273
}
269274
x
270275
}, layers, layer_data)

0 commit comments

Comments
 (0)