Persistent selection with the shift key only works on the last plot


In an R Notebook or flexdashboard, when I create more than one plot using the plotly and crosstalk libraries, persistent selection of lines or points using the shift key seems to only work on the last plot.

For example, in the code below, I create two plotly plots in an R Notebook and in both, I leave the persistent parameter as the default persistent = FALSE. After I knit the r markdown to html, both plots come out as expected, but persistent selection with shift only works for the second plot (Chart B). In the first plot, shift has no effect and there is no persistent selection of the points.

If I make Chart A the second plot, then the reverse happens, where persistent selection with shift no longer works in Chart B.

If I set persistent = TRUE in the first plot, persistent selection works, but then the ability to look only at individual points or lines is lost.

Any idea what I might be doing wrong? Many thanks!


title: "R Notebook"
    df_print: paged

```{r setup, include=FALSE}

### Chart A

```{r echo=TRUE}
shared_iris <- SharedData$new(iris)
plot_ly(shared_iris, x = ~Petal.Length, y = ~Petal.Width) %>%
    add_markers() %>%
    highlight(selectize = TRUE)

### Chart B

```{r echo=TRUE}
sd <- SharedData$new(txhousing, ~city)
plot_ly(sd, x = ~date, y = ~median) %>%
    group_by(city) %>%
    add_lines() %>%
    highlight(selectize = TRUE)