From d551de7fc4dc1255541825e7e001b2436f6c7c5d Mon Sep 17 00:00:00 2001 From: Maryam Kaka Date: Tue, 12 Sep 2023 13:29:06 +0000 Subject: [PATCH] Update chart dimensions to update on chart height resize --- packages/polaris-viz/CHANGELOG.md | 2 ++ .../components/ChartDimensions/ChartDimensions.tsx | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/polaris-viz/CHANGELOG.md b/packages/polaris-viz/CHANGELOG.md index 6caa839395..6d07425e22 100644 --- a/packages/polaris-viz/CHANGELOG.md +++ b/packages/polaris-viz/CHANGELOG.md @@ -7,6 +7,8 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +- Fixed issue where chart would not resize on height change + ## [9.10.7] - 2023-09-06 ### Changed diff --git a/packages/polaris-viz/src/components/ChartContainer/components/ChartDimensions/ChartDimensions.tsx b/packages/polaris-viz/src/components/ChartContainer/components/ChartDimensions/ChartDimensions.tsx index 38b1a82e6f..b86aa9dc7c 100644 --- a/packages/polaris-viz/src/components/ChartContainer/components/ChartDimensions/ChartDimensions.tsx +++ b/packages/polaris-viz/src/components/ChartContainer/components/ChartDimensions/ChartDimensions.tsx @@ -55,7 +55,8 @@ export function ChartDimensions({ const updateDimensions = useCallback(() => { if ( - previousEntry?.contentRect.width === entry?.contentRect.width || + (previousEntry?.contentRect.width === entry?.contentRect.width && + previousEntry?.contentRect.height === entry?.contentRect.height) || entry == null ) { return; @@ -65,7 +66,7 @@ export function ChartDimensions({ const {x, y} = entry.target.getBoundingClientRect(); setChartDimensions({width, height, x, y: y + window.scrollY}); - }, [entry, previousEntry?.contentRect.width]); + }, [entry, previousEntry?.contentRect]); const debouncedUpdateDimensions = useDebouncedCallback(() => { updateDimensions();