Skip to content

Omnidoc: Correcting documented default values for Area#6615

Merged
ckifer merged 1 commit intomainfrom
area-default-props
Nov 13, 2025
Merged

Omnidoc: Correcting documented default values for Area#6615
ckifer merged 1 commit intomainfrom
area-default-props

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Nov 13, 2025

Description

Also removed layout prop from Area that we never read - this should have been done in 3.0

Related Issue

#6069

Summary by CodeRabbit

Release Notes

  • New Features

    • Added automatic animation mode for enhanced server-side rendering compatibility.
  • Bug Fixes

    • Fixed default value handling to preserve numeric and boolean types correctly.
    • Improved layout-aware animation rendering.
  • Documentation

    • Updated API documentation with accurate default values and improved type definitions.
    • Enhanced animation properties documentation with new defaults.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

This pull request refactors the Area component to support automatic animation detection and derive layout from context, while standardizing default value handling across the codebase. Changes include introducing useCartesianChartLayout hook, updating Area's isAnimationActive to support 'auto' mode, removing the layout prop, and adjusting default value representations to preserve original types instead of coercing to strings.

Changes

Cohort / File(s) Summary
omnidoc test infrastructure
omnidoc/omnidoc.spec.ts, omnidoc/readProject.spec.ts, omnidoc/readStorybookDoc.spec.ts
Removed "Area" from known issues lists; added tests for Area.animationDuration (1500) and Area.animationBegin (0) default values; introduced stringifyDefaultValue helper for consistent default value comparison across tests.
omnidoc readers
omnidoc/readProject.ts
Modified getDefaultValueFromObject to return \{ type: 'known', value \} with original value type instead of string coercion, preserving boolean and numeric types.
Chart layout context
src/context/chartLayoutContext.tsx
Added new public hook useCartesianChartLayout() that returns CartesianLayout | undefined by filtering to horizontal/vertical layouts only.
Area component
src/cartesian/Area.tsx
Replaced direct layout prop usage with useCartesianChartLayout hook; changed isAnimationActive from boolean to boolean | 'auto' with 'auto' as default; added default props for type ('linear') and label (false); added null-guard when layout unavailable.
Storybook animation props
storybook/stories/API/props/AnimationProps.ts
Updated isAnimationActive to support 'auto' type with defaultValue 'auto'; added defaultValue 1500 to animationDuration; added defaultValue 'ease' to animationEasing; removed defaultValue from animationBegin.
Storybook axis props
storybook/stories/API/props/CartesianComponentShared.ts
Added defaultValue: 0 to both xAxisId and yAxisId exports.
Storybook style props
storybook/stories/API/props/Styles.ts
Changed LineStyle.type property from \default: 'linear'\\ to \defaultValue: 'linear'\\ to align with Storybook conventions.
Storybook Area stories
storybook/stories/API/cartesian/Area.stories.tsx
Added dot property to argTypes with multi-type documentation (Boolean | Object | ReactElement | Function) and defaultValue false.
API documentation
www/src/docs/api/Area.ts
Major update: removed layout prop; added dataKey prop; changed isAnimationActive to Boolean | 'auto' with defaultValue 'auto'; converted boolean/enum string-encoded defaults to actual types; made baseLine optional; updated animationEasing default from "'ease'" to 'ease'; added explicit ApiDoc type annotation.
API type definitions
www/src/docs/api/types.ts
Expanded ApiProps.defaultVal type from \string \| number \| null\\ to \string \| number \| boolean \| null\\ to support boolean default values.
API documentation view
www/src/views/APIViewNew.tsx
Changed rendering of defaultVal from plain span to JSON-wrapped code element for formatted display of default values.
Component tests
test/cartesian/Area.spec.tsx, test/component/Legend.spec.tsx
Updated test expectations: changed isAnimationActive from true to 'auto'; added label: false; added type: 'linear'; added positions: undefined to tooltip payloads.

Sequence Diagram(s)

sequenceDiagram
    participant Area as Area Component
    participant Hook as useCartesianChartLayout()
    participant ChartContext as Chart Context
    participant Layout as CartesianLayout

    Area->>Hook: Request layout
    Hook->>ChartContext: Read chart layout via useChartLayout()
    ChartContext-->>Hook: Return current layout
    
    alt Layout is 'horizontal' or 'vertical'
        Hook-->>Area: Return CartesianLayout
        Area->>Area: Render with derived layout
    else Layout is other value or undefined
        Hook-->>Area: Return undefined
        Area->>Area: Return null (guard)
    end

    Note over Area: If isAnimationActive is 'auto':<br/>Resolve to !Global.isSsr
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • www/src/docs/api/Area.ts: High density of prop signature changes and default value conversions; requires careful verification that type updates and removals (especially layout removal) are intentional and complete.
  • src/cartesian/Area.tsx: Layout refactoring introduces new hook dependency and conditional rendering guard; verify animation sequence and clip rect logic correctly use derived layout.
  • omnidoc test files: Multiple coordinated changes to test infrastructure and default value handling; ensure test assertions align with new type preservation behavior.
  • Type expansion in www/src/docs/api/types.ts: Boolean addition to defaultVal union requires verification that all consumers handle the new type correctly.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • ckifer

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It lacks required template sections including Motivation and Context, How Has This Been Tested, Types of changes, and the verification checklist. Complete the PR description by adding the missing template sections: explain the motivation for correcting default values, describe testing performed, select applicable change types, and verify the checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: correcting documented default values for the Area component, which aligns with the comprehensive scope of changes across omnidoc, test files, and component definitions.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch area-default-props

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c3ffe3 and 88710c1.

📒 Files selected for processing (15)
  • omnidoc/omnidoc.spec.ts (4 hunks)
  • omnidoc/readProject.spec.ts (1 hunks)
  • omnidoc/readProject.ts (1 hunks)
  • omnidoc/readStorybookDoc.spec.ts (1 hunks)
  • src/cartesian/Area.tsx (9 hunks)
  • src/context/chartLayoutContext.tsx (2 hunks)
  • storybook/stories/API/cartesian/Area.stories.tsx (1 hunks)
  • storybook/stories/API/props/AnimationProps.ts (1 hunks)
  • storybook/stories/API/props/CartesianComponentShared.ts (1 hunks)
  • storybook/stories/API/props/Styles.ts (1 hunks)
  • test/cartesian/Area.spec.tsx (7 hunks)
  • test/component/Legend.spec.tsx (1 hunks)
  • www/src/docs/api/Area.ts (11 hunks)
  • www/src/docs/api/types.ts (1 hunks)
  • www/src/views/APIViewNew.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any user-facing strings or formatting choices in the library code; leave internationalization to library users

Files:

  • src/context/chartLayoutContext.tsx
  • src/cartesian/Area.tsx
🧠 Learnings (3)
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : Mock getBoundingClientRect using test/helper/MockGetBoundingClientRect.ts when rendering Recharts components (e.g., Tooltip, Legend, charts)

Applied to files:

  • test/cartesian/Area.spec.tsx
  • src/context/chartLayoutContext.tsx
  • src/cartesian/Area.tsx
📚 Learning: 2025-10-25T07:36:02.229Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-25T07:36:02.229Z
Learning: Recharts aims for simple, declarative, and composable charts; prioritize consistency, usability, performance, and accessibility

Applied to files:

  • src/context/chartLayoutContext.tsx
  • src/cartesian/Area.tsx
📚 Learning: 2025-10-25T07:35:46.188Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-10-25T07:35:46.188Z
Learning: Applies to test/**/*.test.{ts,tsx} : When testing selectors, verify render counts using the spy and rerenderSameComponent from createSelectorTestCase

Applied to files:

  • omnidoc/omnidoc.spec.ts
🧬 Code graph analysis (6)
src/context/chartLayoutContext.tsx (1)
src/util/types.ts (1)
  • CartesianLayout (49-49)
storybook/stories/API/props/CartesianComponentShared.ts (1)
storybook/StorybookArgs.ts (1)
  • StorybookArg (13-48)
omnidoc/omnidoc.spec.ts (1)
omnidoc/DocReader.ts (1)
  • DefaultValue (1-1)
src/cartesian/Area.tsx (3)
src/util/types.ts (1)
  • CartesianLayout (49-49)
src/context/chartLayoutContext.tsx (1)
  • useCartesianChartLayout (137-143)
storybook/stories/API/props/AnimationProps.ts (1)
  • isAnimationActive (29-36)
storybook/stories/API/props/AnimationProps.ts (1)
storybook/StorybookArgs.ts (1)
  • StorybookArg (13-48)
www/src/docs/api/Area.ts (1)
www/src/docs/api/types.ts (1)
  • ApiDoc (20-26)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
storybook/stories/API/props/Styles.ts (1)

128-128: LGTM! Standardizing property name for consistency.

The change from default to defaultValue correctly aligns with Storybook's Args interface and matches the naming convention used throughout the rest of the file (e.g., lines 9, 40, 50, 72).

storybook/stories/API/props/CartesianComponentShared.ts (1)

22-22: Verified ✓ Changes are correct.

Confirmed that 0 is indeed the default value for both xAxisId and yAxisId in the Area component (see defaultAreaProps in src/cartesian/Area.tsx, lines 1083-1084). The Storybook documentation updates correctly reflect these actual component defaults, and using the numeric type aligns with the PR's goal to preserve original types.

www/src/views/APIViewNew.tsx (1)

67-67: LGTM! Proper handling of expanded default value types.

The use of JSON.stringify correctly handles the expanded type of defaultVal (which now includes boolean). Wrapping in a <code> element improves visual presentation.

omnidoc/readProject.ts (1)

134-144: Excellent improvement to preserve default value types.

Removing the String(value) coercion preserves the original type of default values (numbers, booleans, etc.), which improves type fidelity throughout the documentation pipeline.

omnidoc/readProject.spec.ts (1)

861-863: LGTM! Test validates numeric default value preservation.

The test correctly verifies that numeric defaults remain as numbers rather than being coerced to strings.

test/component/Legend.spec.tsx (1)

1852-1885: LGTM! Test expectations updated for corrected Area defaults.

The updated assertions reflect the new default values for Area:

  • isAnimationActive: 'auto' enables automatic animation detection
  • label: false and type: 'linear' are now explicitly documented defaults
omnidoc/readStorybookDoc.spec.ts (1)

196-198: LGTM! Test ensures Storybook docs preserve numeric types.

Validates that the Storybook documentation reader maintains numeric default values, ensuring consistency with the project-based documentation reader.

www/src/docs/api/types.ts (1)

12-12: LGTM! Type expansion supports boolean default values.

Adding boolean to the defaultVal type enables accurate documentation of boolean props, supporting the broader effort to preserve original default value types.

src/context/chartLayoutContext.tsx (1)

137-143: LGTM! Well-designed public hook for Cartesian layout.

The useCartesianChartLayout hook provides type-safe access to Cartesian-specific layout information, following the established patterns in this file. The implementation is clean and properly filters non-Cartesian layouts.

test/cartesian/Area.spec.tsx (1)

790-795: Tests cover the new defaults.

Nice to see the legend payload now asserts 'auto', 'linear', and label: false, so we’ll catch any drift from the new runtime defaults.

omnidoc/omnidoc.spec.ts (1)

199-206: Stringifying project defaults avoids false negatives.

Converting project-side defaults to strings before comparing with JSDoc keeps booleans and numbers from triggering spurious failures—nice tightening of the omnidoc guardrail.

storybook/stories/API/props/AnimationProps.ts (1)

17-34: Docs reflect runtime defaults.

Surfacing 1500 / 'ease' / 'auto' directly through the arg defaults keeps Storybook perfectly in step with the component behaviour.

src/cartesian/Area.tsx (1)

752-755: SSR-aware animation toggle.

Routing 'auto' through !Global.isSsr gives callers a sane default—animations stay off during SSR but flip on in the browser without extra props.

www/src/docs/api/Area.ts (1)

58-249: API defaults now share real types.

Switching to boolean/number defaults (and documenting 'auto') keeps the published API in lockstep with what Area actually ships—great for omnidoc parity.

Comment on lines +35 to +47
dot: {
description: `If false set, dots will not be drawn. If true set, dots will be drawn which have the props
calculated internally. If object set, dots will be drawn which have the props merged by the internal
calculated props and the option. If ReactElement set, the option can be the custom dot element.If set
a function, the function will be called to render customized dot.`,
defaultValue: false,
table: {
type: {
summary: 'Boolean | Object | ReactElement | Function',
category: 'Style',
},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix argType structure: category should be at table level.

The category property should be directly under table, not nested under table.type. Compare with the correct structure in stackId (lines 21-26).

Apply this diff to fix the structure:

     dot: {
       description: `If false set, dots will not be drawn. If true set, dots will be drawn which have the props
       calculated internally. If object set, dots will be drawn which have the props merged by the internal
       calculated props and the option. If ReactElement set, the option can be the custom dot element.If set
       a function, the function will be called to render customized dot.`,
       defaultValue: false,
       table: {
         type: {
           summary: 'Boolean | Object | ReactElement | Function',
-          category: 'Style',
         },
+        category: 'Style',
       },
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dot: {
description: `If false set, dots will not be drawn. If true set, dots will be drawn which have the props
calculated internally. If object set, dots will be drawn which have the props merged by the internal
calculated props and the option. If ReactElement set, the option can be the custom dot element.If set
a function, the function will be called to render customized dot.`,
defaultValue: false,
table: {
type: {
summary: 'Boolean | Object | ReactElement | Function',
category: 'Style',
},
},
},
dot: {
description: `If false set, dots will not be drawn. If true set, dots will be drawn which have the props
calculated internally. If object set, dots will be drawn which have the props merged by the internal
calculated props and the option. If ReactElement set, the option can be the custom dot element.If set
a function, the function will be called to render customized dot.`,
defaultValue: false,
table: {
type: {
summary: 'Boolean | Object | ReactElement | Function',
},
category: 'Style',
},
},
🤖 Prompt for AI Agents
In storybook/stories/API/cartesian/Area.stories.tsx around lines 35 to 47, the
argType for `dot` incorrectly places `category` under `table.type`; move
`category: 'Style'` out one level to be directly under `table` (alongside `type`
and `defaultValue`/`description`) so the structure matches `stackId` (lines
21-26) — i.e., keep `table.type.summary` as the type and add `table.category =
'Style'`.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 87.87879% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.14%. Comparing base (0c3ffe3) to head (88710c1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/cartesian/Area.tsx 80.00% 2 Missing ⚠️
src/context/chartLayoutContext.tsx 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6615      +/-   ##
==========================================
- Coverage   94.15%   94.14%   -0.01%     
==========================================
  Files         493      493              
  Lines       41081    41080       -1     
  Branches     4773     4778       +5     
==========================================
- Hits        38681    38676       -5     
- Misses       2395     2399       +4     
  Partials        5        5              

☔ 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.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.12MB 448 bytes (0.04%) ⬆️
recharts/bundle-es6 967.85kB 362 bytes (0.04%) ⬆️
recharts/bundle-umd 509.64kB 129 bytes (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 180 bytes 27.12kB 0.67%
context/chartLayoutContext.js 268 bytes 8.8kB 3.14%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Area.js 180 bytes 25.27kB 0.72%
context/chartLayoutContext.js 182 bytes 7.64kB 2.44%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 129 bytes 509.64kB 0.03%

fillOpacity: 0.6,
hide: false,
isAnimationActive: !Global.isSsr,
isAnimationActive: 'auto',
Copy link
Member

Choose a reason for hiding this comment

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

What is this? Has this always been available? lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added it now. Just a serializable name for what is going on.

Copy link
Member

Choose a reason for hiding this comment

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

Ah duh, I missed the check below this

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.

2 participants