diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx index 97df6638daad552137036bcd2907082185f251eb..53ebf20563330b5f062f7f63c59389942fb95e7a 100644 --- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx +++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx @@ -387,6 +387,7 @@ export function CustomReport() { ]); const getGraphData = useMemo(() => { + // TODO: fix me - state mutations should not happen inside `useMemo` setDataCheck(false); return createCustomSpreadsheet({ startDate, @@ -454,6 +455,16 @@ export function CustomReport() { const navigate = useNavigate(); const [, setScrollWidth] = useState(0); + useEffect(() => { + if (disabledLegendLabel(mode, graphType, 'disableLegend')) { + setViewLegendPref(false); + } + + if (disabledLegendLabel(mode, graphType, 'disableLabel')) { + setViewLabelsPref(false); + } + }, [setViewLegendPref, setViewLabelsPref, mode, graphType]); + if (!allIntervals || !data) { return null; } @@ -516,15 +527,9 @@ export function CustomReport() { const isItemDisabled = (type: string) => { switch (type) { case 'ShowLegend': { - if (disabledLegendLabel(mode, graphType, 'disableLegend')) { - setViewLegendPref(false); - } return disabledLegendLabel(mode, graphType, 'disableLegend') || false; } case 'ShowLabels': { - if (disabledLegendLabel(mode, graphType, 'disableLabel')) { - setViewLabelsPref(false); - } return disabledLegendLabel(mode, graphType, 'disableLabel') || false; } default: diff --git a/upcoming-release-notes/3484.md b/upcoming-release-notes/3484.md new file mode 100644 index 0000000000000000000000000000000000000000..fd0f8fa1a6a3da74010471c39e6d72482621c0e3 --- /dev/null +++ b/upcoming-release-notes/3484.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Custom reports - fix opening table reports crashing the page.