Skip to content

Commit

Permalink
Fix stacked area arity bug regression
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelnesen committed Jan 8, 2025
1 parent f3dd276 commit d921577
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 47 deletions.
4 changes: 4 additions & 0 deletions packages/polaris-viz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Fixed issue in `<StackedArea />` where changing data series length would cause the chart to throw an error

### Changed

- Removed main percentage label from `<FunnelChartNext />`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@ export function StackedAreas({
return (
<Fragment>
{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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,47 +100,5 @@ describe('<StackedAreas />', () => {
duration: 100,
});
});

it('renders and animates when series length changes', () => {
const singleSeriesValues = [
[
[163, 269],
[0, 0],
],
] as StackedSeries[];

const stackedArea = mount(
<svg>
<StackedAreas
{...mockProps}
stackedValues={singleSeriesValues}
zeroLineValues={singleSeriesValues}
/>
</svg>,
);

expect(stackedArea).toContainReactComponentTimes(AnimatedArea, 1);

// Update with two series
stackedArea.setProps({
children: (
<StackedAreas
{...mockProps}
stackedValues={mockStackedValues}
zeroLineValues={mockStackedValues}
/>
),
});

const stacks = stackedArea.findAll(AnimatedArea);

expect(stackedArea).toContainReactComponentTimes(AnimatedArea, 2);
expect(stacks[0]).toHaveReactProps({
duration: 275,
});
expect(stacks[1]).toHaveReactProps({
duration: 275,
});
});
});
});

0 comments on commit d921577

Please sign in to comment.