From 763f68e8b258c55f46cc085be5c6987a6deb698a Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Tue, 10 Sep 2024 12:18:38 +0200 Subject: [PATCH] fix: Do not initialize height when not layouting --- app/components/react-grid.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/react-grid.tsx b/app/components/react-grid.tsx index 3d651c933..6bbb2e456 100644 --- a/app/components/react-grid.tsx +++ b/app/components/react-grid.tsx @@ -11,7 +11,9 @@ import { match } from "ts-pattern"; import { useStyles as useChartContainerStyles } from "@/charts/shared/containers"; import { getChartWrapperId } from "@/components/chart-panel"; +import { hasChartConfigs, isLayouting } from "@/configurator"; import { useTimeout } from "@/hooks/use-timeout"; +import { useConfiguratorState } from "@/src"; const ResponsiveReactGridLayout = WidthProvider(Responsive); @@ -210,6 +212,8 @@ export const ChartGridLayout = ({ resize?: boolean; } & ComponentProps) => { const classes = useStyles(); + const [state] = useConfiguratorState(hasChartConfigs); + const allowHeightInitialization = isLayouting(state); const [mounted, setMounted] = useState(false); const mountedForSomeTime = useTimeout(500, mounted); const chartContainerClasses = useChartContainerStyles(); @@ -237,7 +241,7 @@ export const ChartGridLayout = ({ }, []); useEffect(() => { - if (!mountedForSomeTime) { + if (!mountedForSomeTime || !allowHeightInitialization) { return; } @@ -279,6 +283,7 @@ export const ChartGridLayout = ({ setEnhancedLayouts(newLayouts); } }, [ + allowHeightInitialization, chartContainerClasses.chartContainer, enhancedLayouts, mountedForSomeTime,