Skip to content

[BUG]: Some event payload types don't match what's actually emitted #8147

Open

Description

@camdecoster

Description

Some event types in src/types/core/events.d.ts do not match the payload that plotly.js emits.

Steps to reproduce

  • Register gd.on('plotly_beforeplot', (event) => event.data) and call Plotly.newPlot. The code compiles, but event.data is undefined.
  • Register gd.on('plotly_selected', (event) => event.points) and clear a selection. The code compiles, but event is undefined.
  • Register gd.on('plotly_click', (event) => event.event.clientX) on a scatter3d plot. The code compiles, but event.event is undefined.

Notes

  • This is a follow-up to chore: Add TS types for lifecycle and WebGL context events #8145
  • Required changes:
    • plotly_beforeplot: the payload is the tuple [data, layout, config], but BeforePlotEvent is an object.
    • plotly_selected: the payload is undefined when a selection is cleared, but the callback type does not allow it.
    • PlotMouseEvent.event: gl3d traces emit no event, but the field is required.
    • PlotHoverEvent.xvals and yvals: only cartesian traces set them, but both fields are required.
    • LegendClickEvent.node: the value is an SVG element, but the type is PlotlyHTMLElement.
    • Missing optional fields: xaxes, yaxes, xvals and yvals on click events, selections on plotly_selected, group and label on legend clicks, and subplotId on annotation clicks.
    • parcoords emits plotly_hover and plotly_unhover with {x, y, clientX, clientY, dataIndex, curveNumber}, with no points or event.
  • Fixing plotly_beforeplot and plotly_selected is a changes existing types and could break existing code for some users. This wouldn't be a breaking change because it falls under a bug fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions