Skip to content

feat(donut-s2): Hover - segment hover fade, direct-label color switch, and legend bidirectional highlight - #895

Open
madelineluke wants to merge 2 commits into
feat/donut-direct-labels-ring-gap-sizing-anchorfrom
feat/donut-hover-segment-fade-label-color-switch
Open

feat(donut-s2): Hover - segment hover fade, direct-label color switch, and legend bidirectional highlight#895
madelineluke wants to merge 2 commits into
feat/donut-direct-labels-ring-gap-sizing-anchorfrom
feat/donut-hover-segment-fade-label-color-switch

Conversation

@madelineluke

Copy link
Copy Markdown
Collaborator

Description

Implements the donut-hover spec: hovering a donut segment fades its siblings, switches the hovered segment's direct-label value to its own categorical color, and syncs highlight state bidirectionally with a paired <Legend>.

  • Extends isInteractive so a donut with a SegmentLabel showing value/percent is hover-interactive on its own, with no popover/inspect required. Verified no other mark type declares a segmentLabels field, so this is a no-op everywhere else.
  • Adds a SERIES_ID data transform (reusing the existing generic getSeriesIdTransform helper) whenever a donut is interactive or paired with a highlighting Legend - needed for both hover directions with a Legend to actually match rows, since donut's data never had this field before, unlike Line/Bar.
  • Both SegmentLabel text marks now fade via the same getMarkOpacity mechanism the arc mark already used, and the value line switches to the hovered segment's own categorical color (the name line stays gray-700, unchanged) - matching the Figma reference exactly.
  • Adds legendHighlightSignals to DonutSpecOptions and consumes it on the arc mark, fading non-matching segments when a paired Legend entry is hovered - the reverse direction of the arc's own hover already highlighting the legend generically via userMeta.interactiveMarks.
  • Adds Donut/Features/Hover stories: a bare SegmentLabel case (no popover) and a Legend-paired case demonstrating both hover directions.

Related Issue

planning/specs/donut/donut-hover.json (approved)

Motivation and Context

Today a donut with only a direct label configured (no popover/inspect) produces no hover feedback at all, and even where hover exists (via a popover), the direct label's value never reflects which segment is hovered and never fades with its de-emphasized arc. Separately, a donut paired with a <Legend> never highlighted in either direction, unlike Line/Bar, because the generic legendHighlightSignals mechanism was already being spread into donut's options but silently dropped (untyped, unconsumed), and donut's data was missing the SERIES_ID field the legend's generic hover matching relies on.

How Has This Been Tested?

  • Unit tests added/updated in markUtils.test.ts, donutSpecBuilder.test.ts, donutUtils.test.ts, and a new hover behavior block in segmentLabelUtils.test.tsx.
  • Full vega-spec-builder-s2/react-spectrum-charts-s2 test suite passes (131 suites, 2120 tests).
  • yarn lint and yarn tsc --noEmit are clean (no new errors; two pre-existing unrelated failures confirmed present on main too).
  • Verified live in Storybook via Playwright, using precise on-pixel hover simulation (not bounding-box centers, which land inside a wedge's hole for thin rings): hovering an arc fades siblings to 0.2 opacity, keeps the hovered value's color, and highlights the matching legend entry; hovering a legend entry fades non-matching arcs. Both directions confirmed working end-to-end.

Screenshots (if appropriate):

See the SimpleDirectLabel and WithLegend stories under React Spectrum Charts 2/Donut/Features/Hover in Storybook.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@madelineluke
madelineluke marked this pull request as draft August 27, 2026 15:44
@madelineluke madelineluke mentioned this pull request Aug 27, 2026
10 tasks
@madelineluke
madelineluke force-pushed the feat/donut-hover-segment-fade-label-color-switch branch from 9e2fc9a to ecdee5c Compare August 27, 2026 20:23
@madelineluke
madelineluke changed the base branch from main to feat/donut-direct-labels-ring-gap-sizing-anchor August 27, 2026 20:23
@madelineluke
madelineluke force-pushed the feat/donut-hover-segment-fade-label-color-switch branch from ecdee5c to e25276c Compare August 27, 2026 20:55
@madelineluke
madelineluke marked this pull request as ready for review August 27, 2026 21:15
@madelineluke
madelineluke force-pushed the feat/donut-hover-segment-fade-label-color-switch branch from e25276c to 6c92d33 Compare August 27, 2026 21:31
madelineluke and others added 2 commits August 27, 2026 15:41
…gend bidirectional highlight

- Extend isInteractive so a donut with a SegmentLabel showing value/percent
  is hover-interactive on its own, with no popover/inspect required -
  verified no other mark type declares a segmentLabels field, so this is a
  no-op everywhere else.
- Add a SERIES_ID data transform (reusing the existing generic
  getSeriesIdTransform helper) whenever a donut is interactive or paired
  with a highlighting Legend - needed for both hover directions with a
  Legend to actually match rows, since donut's data never had this field
  before, unlike Line/Bar.
- Both SegmentLabel text marks now fade via the same getMarkOpacity
  mechanism the arc mark already used, and the value line switches to the
  hovered segment's own categorical color (name line stays gray-700),
  matching the Figma reference.
- Add legendHighlightSignals to DonutSpecOptions and consume it on the arc
  mark, fading non-matching segments when a paired Legend entry is
  hovered - the reverse direction of the arc's own hover highlighting the
  legend (which already worked generically via userMeta.interactiveMarks).
- Add Donut/Features/Hover stories: a bare SegmentLabel (no popover) case,
  and a Legend-paired case demonstrating both hover directions.

Verified live in Storybook via precise on-pixel hover simulation, not just
unit tests: hovering an arc fades siblings and highlights the matching
legend entry; hovering a legend entry fades non-matching arcs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
getSegmentLabelValueFill only checked the arc's own HOVERED_ITEM signal, so
hovering a paired Legend entry faded the arc (via legendHighlightSignals)
without switching the matching segment's label color, unlike direct arc hover.
@madelineluke
madelineluke force-pushed the feat/donut-hover-segment-fade-label-color-switch branch from 6c92d33 to b836f13 Compare August 27, 2026 21:43
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

@madelineluke madelineluke changed the title feat(donut-s2): segment hover fade, direct-label color switch, and legend bidirectional highlight feat(donut-s2): Hover - segment hover fade, direct-label color switch, and legend bidirectional highlight Aug 27, 2026
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