Skip to content

A local-first personal finance app

:bug: fix custom reports crashing when opening table (#3484)

Matiss Janis Aboltins37d201b6fbb9
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index 97df6638da..53ebf20563 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 0000000000..fd0f8fa1a6
--- /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.