fix(Sankey): add accessibilityLayer, title, and desc prop support#7153
fix(Sankey): add accessibilityLayer, title, and desc prop support#7153mixelburg wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughReintroduces an accessibility layer to the Sankey chart: adds an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Sankey as Sankey Component
participant Provider as Chart Provider
participant Report as ReportChartProps
participant Root as RootSurface / SVG
Sankey->>Provider: mount with props (accessibilityLayer, title, desc)
Provider->>Report: forward accessibilityLayer and chart config
Report->>Root: render SVG with role/tabindex and optional <title>/<desc>
Root-->>Report: rendered SVG node
Report-->>Provider: injected accessibility layer
Provider-->>Sankey: final composed chart output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7153 +/- ##
=======================================
Coverage 89.61% 89.61%
=======================================
Files 536 536
Lines 40479 40496 +17
Branches 5519 5519
=======================================
+ Hits 36275 36292 +17
Misses 4196 4196
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 1.26kB (0.02%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
|
| barCategoryGap="10%" | ||
| barGap={4} | ||
| barSize={undefined} | ||
| className={className} | ||
| maxBarSize={undefined} | ||
| stackOffset="none" | ||
| syncId={undefined} | ||
| syncMethod="index" | ||
| baseValue={undefined} | ||
| reverseStackOrder={false} |
There was a problem hiding this comment.
none of these props apply except for accessibilityLayer?
| <> | ||
| <SetComputedData computedData={{ links: modifiedLinks, nodes: modifiedNodes }} /> | ||
| <Surface {...attrs} width={width} height={height}> | ||
| <RootSurface otherAttributes={attrs} title={title} desc={desc}> |
There was a problem hiding this comment.
where do width and height get set now?
| <> | ||
| <SetComputedData computedData={{ links: modifiedLinks, nodes: modifiedNodes }} /> | ||
| <Surface {...attrs} width={width} height={height}> | ||
| <RootSurface otherAttributes={attrs} title={title} desc={desc}> |
There was a problem hiding this comment.
I think there are some consequences of moving to RootSurface such as adding ZIndex support unknowingly. I don't think its a good idea to do that outside of something purposeful
…keep accessibilityLayer Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Closing this PR. @ckifer raised valid concerns about the RootSurface approach — introducing ZIndex support as a side effect and the width/height placement question are not straightforward to resolve. The Sankey accessibilityLayer support needs a more targeted approach that doesn't change the Surface component. Will re-open with a cleaner fix if needed. |
## Description Sankey currently rejects the `accessibilityLayer`, `title` and `desc` props at the type level, and even at runtime `title`/`desc` get stripped by `svgPropertiesNoEvents` before they reach `Surface`, so there's no way to give the chart an accessible name or description. This adds the three props to `SankeyProps` and handles them locally in `SankeyImpl`: `title`/`desc` are passed explicitly to the existing `Surface` (which already knows how to render them), and `role`/`tabIndex` default to `application`/`0` when `accessibilityLayer` is on (the default, same as every other chart), while explicit `role`/`tabIndex` props still win. Same precedence logic as `MainChartSurface`. I deliberately did not move Sankey onto `RootSurface` — that was the approach in #7153 and the concern there was that it drags in ZIndex portal support as a side effect. No changes to `Surface` either. Keyboard navigation wiring for Sankey nodes/links is out of scope here; this covers the props and the SVG attributes. ## Related Issue Fixes #7151 ## Motivation and Context Users migrating from 2.x lost the ability to set `accessibilityLayer`/`title`/`desc` on Sankey (TS errors, and silently dropped at runtime). Every other chart supports them. ## How Has This Been Tested? Added an `accessibility` describe block to `test/chart/Sankey.spec.tsx`: default role/tabindex, `accessibilityLayer={false}` omitting them, explicit `role`/`tabIndex` overriding the defaults, and `title`/`desc` rendering. The default-attributes and title/desc tests fail on current main and pass with this change; the full Sankey spec (33 tests), `AccessibilityLayer.spec.tsx` and `Sankey.typed.spec.tsx` all pass locally, plus `tsc` and eslint on the changed files. ## Screenshots (if appropriate): n/a — attribute-only change, no visual difference. ## Types of changes - [x] 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: - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [x] I have added tests to cover my changes. - [ ] I have added a storybook story or VR test, or extended an existing story or VR test to show my changes <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added accessibility support to Sankey charts by default. * Charts now include appropriate keyboard navigation and application semantics. * Added support for custom titles and descriptions for screen readers. * Added options to disable the accessibility layer or override accessibility attributes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Fixes #7151
Problem
The
Sankeychart was missing theaccessibilityLayer,title, anddescprops that all other Recharts chart types support. This caused TypeScript errors and the<title>element was not rendered in the SVG when provided.Root causes:
SankeyPropsdid not declareaccessibilityLayer,title, ordescReportChartPropswas never called, soaccessibilityLayerwas never dispatched to the Redux storeSankeyImplused raw<Surface>instead of<RootSurface>, which handlestitle/descrendering andaccessibilityLayer-basedrole/tabIndexattributesChanges
SurfacewithRootSurfaceinSankeyImplsotitle,desc, and accessibility attributes are handled consistently with all other chartsaccessibilityLayer,title, anddesctoSankeyPropsaccessibilityLayer: truetosankeyDefaultPropsReportChartPropsin theSankeywrapper component to dispatchaccessibilityLayerto the Redux storeSurfaceimportTests
Added 4 new tests to
test/chart/Sankey.spec.tsx:role=applicationandtabIndex=0by default (accessibilityLayer=true)role/tabIndexwhenaccessibilityLayer=falsetitleprop renders a<title>elementdescprop renders a<desc>elementAll 27 tests pass.
Summary by CodeRabbit
New Features
Tests