Skip to content

Fix exception when Text children are empty and scaleToFit=true#6282

Merged
ckifer merged 1 commit intomainfrom
scaleToFit
Sep 5, 2025
Merged

Fix exception when Text children are empty and scaleToFit=true#6282
ckifer merged 1 commit intomainfrom
scaleToFit

Conversation

@PavelVanecek
Copy link
Collaborator

Description

Text requires children but it doesn't need to throw errors if children are empty does it.

Related Issue

Fixes #6190

Copilot AI review requested due to automatic review settings September 5, 2025 12:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an exception that occurs when Text components have empty children and scaleToFit=true. The fix adds a guard condition to return null early when there are no words to render, preventing downstream errors.

  • Added early return condition when wordsByLines is empty
  • Added comprehensive test coverage for scaleToFit functionality
  • Added specific test case for empty children scenario

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/component/Text.tsx Added guard condition to prevent rendering when no text content exists
test/component/Text.spec.tsx Added test suite covering scaleToFit behavior including edge case with empty children

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (9ffd7c8) to head (5f1f821).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6282      +/-   ##
==========================================
+ Coverage   96.61%   96.63%   +0.01%     
==========================================
  Files         221      221              
  Lines       20157    20157              
  Branches     4134     4137       +3     
==========================================
+ Hits        19475    19478       +3     
+ Misses        675      672       -3     
  Partials        7        7              

☔ 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 Sep 5, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.04MB 29 bytes (0.0%) ⬆️
recharts/bundle-es6 894.24kB 29 bytes (0.0%) ⬆️
recharts/bundle-umd 485.78kB 14 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

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

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Text.js 29 bytes 9.43kB 0.31%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/Text.js 29 bytes 8.37kB 0.35%

@ckifer ckifer merged commit 5d4769b into main Sep 5, 2025
26 of 27 checks passed
@PavelVanecek PavelVanecek deleted the scaleToFit branch September 5, 2025 13: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.

scaleToFit={true} in Text component causes TypeError: Cannot read properties of undefined (reading 'width')

3 participants