From d92157719af4169e342f083ce148a3648735d34e Mon Sep 17 00:00:00 2001 From: Michael Nesen Date: Wed, 8 Jan 2025 16:34:18 +0000 Subject: [PATCH] Fix stacked area arity bug regression --- packages/polaris-viz/CHANGELOG.md | 4 ++ .../components/StackedAreas/StackedAreas.tsx | 5 --- .../StackedAreas/tests/StackedAreas.test.tsx | 42 ------------------- 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/packages/polaris-viz/CHANGELOG.md b/packages/polaris-viz/CHANGELOG.md index 4e5af7560..141c3b982 100644 --- a/packages/polaris-viz/CHANGELOG.md +++ b/packages/polaris-viz/CHANGELOG.md @@ -7,6 +7,10 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased +### Fixed + +- Fixed issue in `` where changing data series length would cause the chart to throw an error + ### Changed - Removed main percentage label from `` diff --git a/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/StackedAreas.tsx b/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/StackedAreas.tsx index 0d39b14de..a9f656189 100644 --- a/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/StackedAreas.tsx +++ b/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/StackedAreas.tsx @@ -86,13 +86,8 @@ export function StackedAreas({ return ( {stackedValues.map((data, index) => { - const isSeriesLengthIncreasing = - previousStackedValues && - previousStackedValues.length < stackedValues.length; - const dataIsValidForAnimation = !previousStackedValues || - isSeriesLengthIncreasing || data.length === previousStackedValues[index]?.length; const AreaComponent = dataIsValidForAnimation ? AnimatedArea : Area; diff --git a/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/tests/StackedAreas.test.tsx b/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/tests/StackedAreas.test.tsx index 340b76701..e142fdc50 100644 --- a/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/tests/StackedAreas.test.tsx +++ b/packages/polaris-viz/src/components/StackedAreaChart/components/StackedAreas/tests/StackedAreas.test.tsx @@ -100,47 +100,5 @@ describe('', () => { duration: 100, }); }); - - it('renders and animates when series length changes', () => { - const singleSeriesValues = [ - [ - [163, 269], - [0, 0], - ], - ] as StackedSeries[]; - - const stackedArea = mount( - - - , - ); - - expect(stackedArea).toContainReactComponentTimes(AnimatedArea, 1); - - // Update with two series - stackedArea.setProps({ - children: ( - - ), - }); - - const stacks = stackedArea.findAll(AnimatedArea); - - expect(stackedArea).toContainReactComponentTimes(AnimatedArea, 2); - expect(stacks[0]).toHaveReactProps({ - duration: 275, - }); - expect(stacks[1]).toHaveReactProps({ - duration: 275, - }); - }); }); });