Skip to content

feat(s2): reset interaction state on data updates and rebuilds - #1098

Open
madelineluke wants to merge 1 commit into
feat/s2-keyed-mark-updatesfrom
feat/s2-state-retention
Open

madelineluke wants to merge 1 commit into
feat/s2-keyed-mark-updatesfrom
feat/s2-state-retention

Conversation

@madelineluke

Copy link
Copy Markdown
Collaborator

Fixes #1082

Stacked on #1080. Retarget to main after #1080 merges.

What changes for consumers

Following the chart stability RFC:

  • Data updates and rebuilds close open popovers and action bars, clear the selection, reset hover and the tooltip, and drop hidden legend series that no longer exist in the data.
  • No-op and signal-only updates keep everything. Passing equal data in a new array counts as a no-op.
  • Series and categories that return after a data update now keep their first-appearance order and colors, as on a fresh mount. Before, they moved to the end. This was a pre-existing bug on main.

How

  • View host: on a table change it resets the interaction signals (selection, hover, highlighted group) to their initial values in the same update, then calls a new onInteractionReset callback. It also calls the callback after a rebuild.
  • useInteractionReset: closes registered dialogs (popovers and the lab action bar), clears selectedData, hides the tooltip, and prunes uncontrolled hidden series using the legend entry scales.
  • Spec builder:
    • Single-field discrete domains sort by min(rscMarkId).
    • The legend aggregate carries min(rscMarkId) and is sorted, so legend entries line up with the domain.

Behavior to be aware of

  • A rebuild closes open popovers, even when the consumer triggered the rebuild.
  • A controlled hiddenSeries prop is never pruned; that's the consumer's to manage.
  • Focus signals are not reset.
  • Row ids (rscMarkId) are reassigned on every data update, so selection can't survive one. A possible follow-up: keep the selection when the row still exists, keyed by idKey. That would diverge from the RFC.

Testing

  • Chart.interactionRetention.test.tsx: the keep/reset matrix for popover, selection, hover, tooltip and hidden series.
  • Chart.stability.test.tsx: restored series and bar category order.
  • Unit tests for the view host, the adapter, the scale builder and the legend builder.
  • Removed the test.fail markers for data updates and rebuilds from browser/interactionRetention.test.ts. The SVG cases pass. Canvas screenshot diffs are text antialiasing; main shows similar flakiness.

Data updates and rebuilds close open popovers, clear the selection, reset
hover and tooltips, and prune hidden legend series that no longer exist.
Discrete domains and legend entries keep first-appearance order so restored
series and categories return to their original position.

Fixes #1082

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant