Skip to content

ResponsiveContainer only shrinks in the dimensions where it needs to shrink#6367

Merged
ckifer merged 5 commits intomainfrom
responsivecontainer
Sep 24, 2025
Merged

ResponsiveContainer only shrinks in the dimensions where it needs to shrink#6367
ckifer merged 5 commits intomainfrom
responsivecontainer

Conversation

@PavelVanecek
Copy link
Collaborator

Description

Only apply the overflow when necessary, not always.

Related Issue

Fixes #6245 I think

Hope it doesn't cause more trouble than it solves!

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

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 pull request fixes an issue with ResponsiveContainer where it was applying overflow styles unconditionally, causing problems when using aspect ratios with fixed dimensions. The fix ensures that overflow styles are only applied when the dimension is percentage-based and needs to shrink.

  • Extracted chart dimension calculation logic into a reusable utility function
  • Added conditional overflow styling that only applies when dimensions are percentage-based
  • Updated type definitions to be more specific about percentage vs number values

Reviewed Changes

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

Show a summary per file
File Description
src/component/responsiveContainerUtils.ts New utility file containing extracted dimension calculation and conditional overflow styling logic
src/component/ResponsiveContainer.tsx Refactored to use new utility functions and improved type definitions
src/util/types.ts Added Percent type alias for better type safety
src/util/DataUtils.ts Updated isPercent function to use the new Percent type
test/component/responsiveContainerUtils.spec.ts Comprehensive test coverage for the new utility functions
test-vr/tests/ResponsiveContainer.spec-vr.tsx Updated test descriptions for clarity
scripts/vitest-build.config.ts Added .stryker-tmp to exclude list
scripts/snapshots/*.txt Updated build snapshots to include new utility file

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 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.74%. Comparing base (0a0b007) to head (063fc3d).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6367      +/-   ##
==========================================
+ Coverage   61.68%   61.74%   +0.06%     
==========================================
  Files         409      410       +1     
  Lines       37903    37967      +64     
  Branches     4317     4330      +13     
==========================================
+ Hits        23380    23444      +64     
  Misses      14409    14409              
  Partials      114      114              

☔ 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 22, 2025

Bundle Report

Changes will increase total bundle size by 7.11kB (0.29%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.05MB 3.44kB (0.33%) ⬆️
recharts/bundle-es6 906.51kB 3.05kB (0.34%) ⬆️
recharts/bundle-umd 488.53kB 618 bytes (0.13%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/ResponsiveContainer.js -251 bytes 7.27kB -3.34%
component/responsiveContainerUtils.js (New) 3.69kB 3.69kB 100.0% 🚀
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
component/ResponsiveContainer.js -268 bytes 6.19kB -4.15%
component/responsiveContainerUtils.js (New) 3.32kB 3.32kB 100.0% 🚀
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 618 bytes 488.53kB 0.13%

@PavelVanecek
Copy link
Collaborator Author

Hm okay so this makes things worse than before. Back to the drawing board

@PavelVanecek
Copy link
Collaborator Author

Okay much better now

Copy link
Member

@ckifer ckifer left a comment

Choose a reason for hiding this comment

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

noice

width?: number;
}

export type Percent = `${number}%`;
Copy link
Member

Choose a reason for hiding this comment

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

this is technically a breaking change.

But I think since things were either checked for percentage or casted to a number we should be ok

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or a bugfix - typescript should have flagged strings other than percentage strings, because those won't work anyway

Copy link
Member

Choose a reason for hiding this comment

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

Yep

@ckifer ckifer merged commit 30e48ba into main Sep 24, 2025
25 of 27 checks passed
@ckifer ckifer deleted the responsivecontainer branch September 24, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResponsiveContainer now has an zero height

3 participants