From 55899f7d3b78850cd7b5304774baab796094bf2e Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Wed, 26 Jul 2023 17:13:51 +0200 Subject: [PATCH] Fixed fit-height for react 18 --- src/area-chart/model/use-chart-model.ts | 3 ++- src/mixed-line-bar-chart/chart-container.tsx | 5 ++++- src/pie-chart/pie-chart.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/area-chart/model/use-chart-model.ts b/src/area-chart/model/use-chart-model.ts index b9602c7c85..5bdae1e695 100644 --- a/src/area-chart/model/use-chart-model.ts +++ b/src/area-chart/model/use-chart-model.ts @@ -60,7 +60,8 @@ export default function useChartModel({ const plotMeasureRef = useRef(null); const hasVisibleSeries = series.length > 0; - const height = useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries]) ?? explicitHeight; + const height = + useHeightMeasure(() => plotMeasureRef.current, !fitHeight, [hasVisibleSeries, fitHeight]) ?? explicitHeight; const stableSetVisibleSeries = useStableEventHandler(setVisibleSeries); diff --git a/src/mixed-line-bar-chart/chart-container.tsx b/src/mixed-line-bar-chart/chart-container.tsx index 9f09421fa3..6515b7bb09 100644 --- a/src/mixed-line-bar-chart/chart-container.tsx +++ b/src/mixed-line-bar-chart/chart-container.tsx @@ -122,7 +122,10 @@ export default function ChartContainer({ const popoverRef = useRef(null); const plotMeasureRef = useRef(null); - const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight || !bottomLabelsHeight); + const measuredHeight = useHeightMeasure(() => plotMeasureRef.current, !fitHeight || !bottomLabelsHeight, [ + fitHeight, + bottomLabelsHeight, + ]); const plotHeight = fitHeight ? (bottomLabelsHeight ? measuredHeight ?? 0 : 0) : explicitPlotHeight; const isRefresh = useVisualRefresh(); diff --git a/src/pie-chart/pie-chart.tsx b/src/pie-chart/pie-chart.tsx index 55ecf33d82..42a2a73638 100644 --- a/src/pie-chart/pie-chart.tsx +++ b/src/pie-chart/pie-chart.tsx @@ -90,7 +90,7 @@ export default ({ const hasLabels = !(hideTitles && hideDescriptions); const isRefresh = useVisualRefresh(); - const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight) ?? explicitHeight; + const height = useHeightMeasure(() => plotRef.current?.svg ?? null, !fitHeight, [fitHeight]) ?? explicitHeight; const dimensions = useMemo( () =>