Skip to content

Fix Legend type#7560

Merged
PavelVanecek merged 2 commits into
mainfrom
legend-types-fix
Jul 16, 2026
Merged

Fix Legend type#7560
PavelVanecek merged 2 commits into
mainfrom
legend-types-fix

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Description

I noticed that Legend has SVG props available on it even though it renders an HTML element. So I fixed the type to remove the SVG things and also changed the any to LegendPayload type to reflect what is going on.

Related Issue

Nobody reported this!

Motivation and Context

Strong typing

How Has This Been Tested?

Unit tests + TS

Screenshots (if appropriate):

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:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • 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

Summary by CodeRabbit

  • Bug Fixes
    • Improved type support for HTML-based legend properties and accessibility attributes.
    • Strengthened legend click-event handling with fully validated payload details.
    • Added coverage ensuring Legend does not forward id and className to the DOM.
  • Tests
    • Updated legend click tests to assert complete mouse event details.
    • Simplified legend alignment visual tests by removing offset-related cases.
  • Documentation
    • Updated a composed chart example to match the current legend rendering API.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48b52f4b-7887-4c7f-9ea5-23a92d8740c7

📥 Commits

Reviewing files that changed from the base of the PR and between ec54d6c and 61173bc.

📒 Files selected for processing (1)
  • test/component/Legend.spec.tsx

Walkthrough

The PR adds an HTML presentation attribute type for legend props, strengthens legend click-event assertions, removes offset-based visual alignment coverage, and simplifies an example callback signature.

Changes

Legend updates

Layer / File(s) Summary
HTML presentation prop contract
src/util/types.ts, src/component/DefaultLegendContent.tsx
Adds PresentationAttributesForHTML and uses it for DefaultLegendContent exported props.
Legend click payload validation
test/component/Legend.spec.tsx
Types the click mock, verifies the emitted payload, index, and click event, and checks that id and className are not forwarded to the DOM.
Alignment test and example cleanup
test-vr/tests/LegendPosition*, www/src/docs/exampleComponents/ComposedChart/BandedChart.tsx
Removes offset handling from alignment visual tests and excludes an unused callback ref.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: ckifer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly reflects the Legend type fix in this PR.
Description check ✅ Passed The description follows the template well and includes all required sections, though the related issue entry is only a placeholder.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch legend-types-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 576 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.45MB 195 bytes (0.01%) ⬆️
recharts/bundle-es6 1.27MB 195 bytes (0.02%) ⬆️
recharts/bundle-umd 586.67kB 186 bytes (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 186 bytes 586.67kB 0.03%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
util/types.js 195 bytes 10.12kB 1.97%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
util/types.js 195 bytes 9.7kB 2.05%

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/util/types.ts`:
- Around line 106-110: Update the PresentationAttributesForHTML type alias to
intersect React’s HTMLAttributes<T> alongside AriaAttributes and
DOMAttributesAdaptChildEvent<P, T>, preserving standard attributes such as
className, style, and id for HTML-rendering components.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52891b0e-6f39-40b2-9109-625f36b151a2

📥 Commits

Reviewing files that changed from the base of the PR and between 48d4f2f and ec54d6c.

⛔ Files ignored due to path filters (3)
  • test-vr/__snapshots__/tests/LegendPosition.spec-vr.tsx-snapshots/Legend-align-with-offset-1-chromium-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/LegendPosition.spec-vr.tsx-snapshots/Legend-align-with-offset-1-firefox-linux.png is excluded by !**/*.png
  • test-vr/__snapshots__/tests/LegendPosition.spec-vr.tsx-snapshots/Legend-align-with-offset-1-webkit-linux.png is excluded by !**/*.png
📒 Files selected for processing (6)
  • src/component/DefaultLegendContent.tsx
  • src/util/types.ts
  • test-vr/tests/LegendPosition.spec-vr.tsx
  • test-vr/tests/LegendPositionComponents.tsx
  • test/component/Legend.spec.tsx
  • www/src/docs/exampleComponents/ComposedChart/BandedChart.tsx

Comment thread src/util/types.ts
@chromatic-com

chromatic-com Bot commented Jul 15, 2026

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 198 tests unchanged
🟢 UI Review: 198 stories published -- no changes
Storybook icon Storybook Publish: 198 stories published

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.20%. Comparing base (48d4f2f) to head (61173bc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7560   +/-   ##
=======================================
  Coverage   88.20%   88.20%           
=======================================
  Files         615      615           
  Lines       14272    14272           
  Branches     3587     3588    +1     
=======================================
  Hits        12588    12588           
  Misses       1494     1494           
  Partials      190      190           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor

@PavelVanecek
PavelVanecek merged commit 14c1a2d into main Jul 16, 2026
65 checks passed
@PavelVanecek
PavelVanecek deleted the legend-types-fix branch July 17, 2026 19:47
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