Skip to content

Omnidoc: Update Label default values#6622

Merged
ckifer merged 1 commit intomainfrom
label-default-value
Nov 13, 2025
Merged

Omnidoc: Update Label default values#6622
ckifer merged 1 commit intomainfrom
label-default-value

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Nov 13, 2025

Related Issue

#6069

Summary by CodeRabbit

  • New Features

    • Label component now supports four new configurable properties: angle, position, textBreakAll, and zIndex, each with documented default values for consistent behavior.
  • Documentation

    • Updated Label component API documentation to reflect accurate default values for all properties, including corrected documentation for position and offset defaults.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Adds Label component default props (angle, position, textBreakAll, zIndex) to the API documentation system. Exports defaultLabelProps constant from Label component. Integrates Label defaults into omnidoc's componentMetaMap, updates test expectations, and revises documentation to reflect standardized defaults.

Changes

Cohort / File(s) Summary
Label component API
src/component/Label.tsx, www/src/docs/api/Label.ts
Added angle, position, textBreakAll, and zIndex properties to LabelProps interface. Exported defaultLabelProps constant with angle (0), position ('middle'), textBreakAll (false), offset (5), and zIndex defaults. Updated API documentation to reflect new defaults and removed null defaults for formatter, value, children, and content.
Omnidoc integration
omnidoc/componentsAndDefaultPropsMap.ts, omnidoc/omnidoc.spec.ts, omnidoc/readProject.ts
Added Label entry to componentMetaMap with defaultLabelProps. Updated omnidoc error messages to include value types. Removed 'Label' from known-issues filter. Reordered default value precedence checking in getDefaultValueOf function.
Storybook documentation
storybook/stories/API/props/LabelListProps.ts
Added defaultValue entry to position prop with summary value 'middle'.
Test expectations
test/cartesian/Bar.spec.tsx, test/component/Label.spec.tsx
Updated imports to source DefaultZIndexes from barrel export instead of direct path. Extended test expectations to include angle (0), position ('middle'), and textBreakAll (false) in label and tooltip payloads.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review the default value precedence reordering logic in omnidoc/readProject.ts to ensure it doesn't change existing behavior for components already integrated
  • Verify consistency of default values across Label component, API docs, Storybook, and test files
  • Confirm test payload expectations align with actual Label component default props propagation

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, containing only a link to a related issue with no explanation of motivation, testing approach, or other template sections. Complete the description by filling in Motivation and Context, How Has This Been Tested, and Types of changes sections from the template.
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: updating Label default values in the omnidoc documentation system.
✨ 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 label-default-value

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 154ce28 and 0d8768a.

📒 Files selected for processing (8)
  • omnidoc/componentsAndDefaultPropsMap.ts (2 hunks)
  • omnidoc/omnidoc.spec.ts (3 hunks)
  • omnidoc/readProject.ts (1 hunks)
  • src/component/Label.tsx (2 hunks)
  • storybook/stories/API/props/LabelListProps.ts (1 hunks)
  • test/cartesian/Bar.spec.tsx (3 hunks)
  • test/component/Label.spec.tsx (8 hunks)
  • www/src/docs/api/Label.ts (2 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/component/Label.tsx
🧠 Learnings (8)
📚 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/component/Label.spec.tsx
  • test/cartesian/Bar.spec.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: Write unit tests using Vitest and React Testing Library

Applied to files:

  • test/component/Label.spec.tsx
  • test/cartesian/Bar.spec.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:

  • test/component/Label.spec.tsx
  • omnidoc/omnidoc.spec.ts
  • test/cartesian/Bar.spec.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:

  • test/component/Label.spec.tsx
  • test/cartesian/Bar.spec.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} : In tests not using createSelectorTestCase, advance timers after renders with vi.runOnlyPendingTimers()

Applied to files:

  • test/component/Label.spec.tsx
  • test/cartesian/Bar.spec.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} : Use expectLastCalledWith instead of toHaveBeenLastCalledWith for typed last-call assertions

Applied to files:

  • test/component/Label.spec.tsx
  • test/cartesian/Bar.spec.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} : Prefer using the createSelectorTestCase helper when writing or modifying tests

Applied to files:

  • test/cartesian/Bar.spec.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 using user-event, initialize with userEvent.setup({ advanceTimers: vi.runOnlyPendingTimers }) or use test/helper/userEventSetup.ts

Applied to files:

  • test/cartesian/Bar.spec.tsx
🧬 Code graph analysis (2)
omnidoc/componentsAndDefaultPropsMap.ts (1)
src/component/Label.tsx (1)
  • defaultLabelProps (554-560)
src/component/Label.tsx (2)
src/component/Text.tsx (1)
  • RenderableText (66-66)
src/zIndex/DefaultZIndexes.tsx (1)
  • DefaultZIndexes (4-81)
⏰ 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 (13)
omnidoc/readProject.ts (1)

337-345: LGTM! Improved default value resolution precedence.

The reordering correctly prioritizes defaultValueFromObject (actual code defaults) before checking the accumulated value. This ensures that explicit default props from componentMetaMap take precedence over other sources, which aligns with the goal of making the code the source of truth for default values.

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

30-32: LGTM! Storybook default aligns with code.

The documented default value of 'middle' correctly matches the position default in defaultLabelProps from src/component/Label.tsx.

omnidoc/componentsAndDefaultPropsMap.ts (1)

4-4: LGTM! Label integrated into documentation system.

The import of defaultLabelProps and its addition to componentMetaMap (line 14) properly integrates Label's default props into the omnidoc documentation system, following the same pattern as other components like Area, ReferenceLine, and Text.

test/cartesian/Bar.spec.tsx (2)

5-16: LGTM! Import uses barrel export.

The import of DefaultZIndexes from the barrel (../../src) instead of the internal path is correct and aligns with the pattern for public API exports.


1022-1047: LGTM! Test expectations updated for new default props.

The test correctly expects the new default props in the label function payload:

  • angle: 0
  • textBreakAll: false
  • position: 'middle'

These match the defaults defined in defaultLabelProps from src/component/Label.tsx (lines 554-560).

test/component/Label.spec.tsx (2)

4-4: LGTM! Consistent import pattern.

The import of DefaultZIndexes from the barrel matches the updated import pattern in test/cartesian/Bar.spec.tsx.


300-318: LGTM! Test expectations include new default props.

The test correctly expects angle: 0 and textBreakAll: false in the content function props, matching the defaults defined in defaultLabelProps. The same pattern is consistently applied throughout the file (lines 464, 468, 500, 504, 538, 542, 613, 616, 644, 647, 678, 681).

omnidoc/omnidoc.spec.ts (2)

124-124: LGTM! Enhanced error messaging.

Adding type information to the error message will help diagnose mismatches between documented and actual default values, especially when comparing strings vs numbers (e.g., '5' vs 5 in the offset prop).


158-158: LGTM! Label removed from known issues.

Removing 'Label' from storybookComponentsWithKnownIssues is correct because Label now has proper default props defined in componentMetaMap (see omnidoc/componentsAndDefaultPropsMap.ts line 14), so the consistency test should now pass.

src/component/Label.tsx (2)

73-99: LGTM! JSDoc properly documents default values.

The @defaultValue tags correctly document the default values for all relevant props, which will help users understand the component's default behavior without looking at the implementation.


554-560: LGTM! Exported defaults with sensible values.

The exported defaultLabelProps includes sensible defaults:

  • angle: 0 (no rotation by default)
  • position: 'middle' (centered positioning)
  • textBreakAll: false (no word breaking by default)

The as const satisfies Partial<Props> ensures type safety while allowing the object to be used as a readonly constant.

www/src/docs/api/Label.ts (2)

36-36: LGTM! Documentation updated to reflect actual default.

The defaultVal: 'middle' correctly documents the default position from defaultLabelProps (src/component/Label.tsx line 558).


46-46: LGTM! Type correction in documentation.

Changing defaultVal from '5' (string) to 5 (number) correctly reflects:

  1. The actual default from defaultLabelProps.offset: 5 (src/component/Label.tsx line 556)
  2. The proper type since offset is documented as type: 'Number' (line 45)

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.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.14%. Comparing base (154ce28) to head (0d8768a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6622      +/-   ##
==========================================
- Coverage   94.14%   94.14%   -0.01%     
==========================================
  Files         493      493              
  Lines       41080    41079       -1     
  Branches     4777     4777              
==========================================
- Hits        38676    38675       -1     
  Misses       2399     2399              
  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 219 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.12MB 113 bytes (0.01%) ⬆️
recharts/bundle-es6 967.91kB 64 bytes (0.01%) ⬆️
recharts/bundle-umd 509.68kB 42 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 42 bytes 509.68kB 0.01%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Label.js 64 bytes 18.41kB 0.35%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Label.js 113 bytes 20.27kB 0.56%

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