Skip to content

Commit 37c4142

Browse files
committed
throw warning if layout.clickmode='select' is used with crosstalk
1 parent e312c56 commit 37c4142

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

R/utils.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,13 @@ verify_key_type <- function(p) {
723723
for (i in seq_along(keys)) {
724724
k <- keys[[i]]
725725
if (is.null(k)) next
726+
if (identical(p$x$layout$clickmode, "select")) {
727+
warning(
728+
"`layout.clickmode` = 'select' is not designed to work well with ",
729+
"the R package's linking framework (i.e. crosstalk support).",
730+
call. = FALSE
731+
)
732+
}
726733
# does it *ever* make sense to have a missing key value?
727734
uk <- uniq(k)
728735
if (length(uk) == 1) {

tests/testthat/test-animate-highlight.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ test_that("SharedData produces key/set in plot_ly", {
1313
expect_false(tr$`_isSimpleKey` %||% FALSE)
1414
})
1515

16+
test_that("Warning is thrown when clickmode='select' is used with crosstalk", {
17+
expect_warning(
18+
plotly_build(layout(p, clickmode = "select")),
19+
"not designed to work well"
20+
)
21+
})
22+
1623
test_that("SharedData produces key/set in ggplotly", {
1724
p <- ggplot(m, aes(x = wt, y = mpg)) + geom_point()
1825
tr <- plotly_build(p)$x$data[[1]]
@@ -24,6 +31,8 @@ test_that("SharedData produces key/set in ggplotly", {
2431
expect_false(tr$`_isSimpleKey` %||% FALSE)
2532
})
2633

34+
35+
2736
test_that("crosstalk keys are inherited in a layer with inherit = FALSE", {
2837

2938
p <- txhousing %>%

0 commit comments

Comments
 (0)