Skip to content

Fix Legend props not appearing in omnidoc website#7203

Merged
PavelVanecek merged 4 commits into
mainfrom
copilot/fix-legend-props-issue
Apr 2, 2026
Merged

Fix Legend props not appearing in omnidoc website#7203
PavelVanecek merged 4 commits into
mainfrom
copilot/fix-legend-props-issue

Conversation

Copilot AI commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Legend component props were missing entirely from the generated API documentation on the website because omnidoc/readProject.ts failed to extract props from React.memo-wrapped components without an explicit type annotation.

Root Cause

Legend = React.memo(LegendImpl, propsAreEqual) produces type React.MemoExoticComponent<typeof LegendImpl>. The alias symbol is MemoExoticComponent and its alias type argument is the wrapped function type (typeof LegendImpl), not the Props type directly. The code path fell through to getTypeArgumentsOfComponentType(), which returned the function type as-is — causing collectPropertiesFromType to find zero properties.

Contrast with components annotated as : ComponentType<Props> (e.g. BarStack) where the alias type argument is the Props type, and those work fine.

Changes

  • omnidoc/readProject.ts — In getPropsType, detect MemoExoticComponent alias and extract the Props type from the inner function's call signature first parameter:

    const innerFunctionType = type.getAliasTypeArguments()[0];
    const params = innerFunctionType?.getCallSignatures()?.[0]?.getParameters() ?? [];
    if (params.length > 0) {
      return params[0].getTypeAtLocation(declaration);
    }
  • src/component/Legend.tsx — Added labelStyle: {} to legendDefaultProps to match the @defaultValue {} JSDoc inherited from DefaultLegendContentProps. This pre-existing inconsistency was hidden while Legend had 0 props discovered; now surfaces and is fixed.

  • www/src/docs/api/LegendAPI.tsx — Regenerated; now contains the full Legend prop list with descriptions, defaults, and examples.

  • test/component/Legend.spec.tsx, test/component/Legend.itemSorter.spec.tsx — Updated expectations for props passed to content functions to include labelStyle: {}.

Related Issue

Legend props don't appear on the website (omnidoc generation bug).

Motivation and Context

Without this fix, the Legend API documentation page on recharts.org shows no props at all, making it unusable as a reference.

How Has This Been Tested?

  • npx vitest run omnidoc/ — 515 tests pass
  • npx vitest run test/component/Legend.spec.tsx test/component/Legend.itemSorter.spec.tsx — 335 tests pass
  • npx tsx omnidoc/generateApiDoc.tsLegendAPI.tsx now emits a full props array

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

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/omnidoc.spec.ts (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/ (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node node /home/REDACTED/work/recharts/recharts/node_modules/.bin/vitest run omnidoc/ -c cat /proc/cpuinfo | grep &#34;physical id&#34; | sort |uniq | wc -l grep /usr/bin/wc o | grep &#34;core igit node 0/x64/bin/node wc -l odules/npm/node_modules/@npmcli/run-script/lib/ncat /proc/cpuinfo | grep &#34;core id&#34; | sort | uniqbash 0/x64/bin/node /usr/bin/sort cat /proc/cpuinfcat sh /usr/bin/wc sort (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Summary by CodeRabbit

  • New Features
    • Legend component now includes a new labelStyle default property, providing enhanced customization options for label styling with sensible default values.

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.3MB 18 bytes (0.0%) ⬆️
recharts/bundle-es6 1.13MB 18 bytes (0.0%) ⬆️
recharts/bundle-umd 547.91kB 14 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Legend.js 18 bytes 9.4kB 0.19%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 14 bytes 547.91kB 0.0%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Legend.js 18 bytes 8.28kB 0.22%

@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.06%. Comparing base (f3ae755) to head (19bdeff).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7203   +/-   ##
=======================================
  Coverage   89.06%   89.06%           
=======================================
  Files         539      539           
  Lines       41011    41012    +1     
  Branches     5553     5554    +1     
=======================================
+ Hits        36527    36528    +1     
  Misses       4476     4476           
  Partials        8        8           

☔ View full report in Codecov by Sentry.
📢 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.

Copilot AI changed the title [WIP] Fix legend props not appearing on the website Fix Legend props not appearing in omnidoc website Apr 2, 2026
Copilot AI requested a review from PavelVanecek April 2, 2026 08:43
@PavelVanecek
PavelVanecek marked this pull request as ready for review April 2, 2026 09:07
@PavelVanecek

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

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: 87862b8b-431e-4efb-9584-a68548ecb933

📥 Commits

Reviewing files that changed from the base of the PR and between f3ae755 and 19bdeff.

📒 Files selected for processing (4)
  • omnidoc/readProject.ts
  • src/component/Legend.tsx
  • test/component/Legend.itemSorter.spec.tsx
  • test/component/Legend.spec.tsx

Walkthrough

The PR extends TypeScript prop-type resolution for MemoExoticComponent aliases in the documentation reader and introduces a new labelStyle default property to the Legend component with corresponding test updates.

Changes

Cohort / File(s) Summary
Type Resolution Enhancement
omnidoc/readProject.ts
Extended getPropsType logic to unwrap MemoExoticComponent alias type arguments, extract the wrapped function type's first parameter, and return it as the props type when available; otherwise falls back to existing behavior.
Legend Component
src/component/Legend.tsx
Added labelStyle: {} as a new default prop to legendDefaultProps.
Test Expectations
test/component/Legend.itemSorter.spec.tsx, test/component/Legend.spec.tsx
Updated test assertions for Legend's content callback to include labelStyle: {} in the expected props object across multiple test cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title "Fix Legend props not appearing in omnidoc website" accurately and concisely describes the main issue being addressed—a bug where Legend component props were missing from generated API documentation.
Description check ✅ Passed The description is comprehensive and follows the template structure, including Root Cause, Changes, Related Issue, Motivation and Context, How Has This Been Tested, Types of changes, and Checklist sections with appropriate selections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 copilot/fix-legend-props-issue

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 and usage tips.

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@PavelVanecek
PavelVanecek merged commit e9963d9 into main Apr 2, 2026
103 of 105 checks passed
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.

Legend props don't appear on the website

2 participants