Skip to content

Plotly hover tooltips only work on the last sticky plot in a .cr-section #190

@pensivedog

Description

@pensivedog

When using multiple Plotly charts as sticky figures inside a single .cr-section, hover tooltips stop working for all charts except the last one. Only the final sticky plot in the section shows interactive hover information.

This happens with plain plotly::plot_ly() as well as ggplotly(), and appears to be related to how Closeread manages sticky containers.

Steps to reproduce

Create a minimal Quarto document using closeread-html and multiple sticky Plotly charts:

---
title: "Closeread + Plotly hover test"
format: closeread-html
execute:
  echo: false
  warning: false
  message: false
---

:::{.cr-section}

Hover over the points on the right and note there is no hoverinfo. @cr-plot1

:::{#cr-plot1}
```{r}
library(plotly)

plot_ly(
  data = mtcars,
  x    = ~hp,
  y    = ~mpg,
  type = "scatter",
  mode = "markers"
)
```
:::

Now hover over the points on the right and note the hover info works properly. @cr-plot2

:::{#cr-plot2}
```{r}
library(plotly)

plot_ly(
  data = mtcars,
  x    = ~wt,
  y    = ~mpg,
  type = "scatter",
  mode = "markers"
)
```

:::

:::

Expected behavior

All sticky Plotly charts should show hover tooltips when mousing over data points.

Actual behavior

Only the last Plotly chart in the .cr-section shows hover tooltips. Earlier sticky plots do not respond to hover.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions