Skip to content

A local-first personal finance app

[AI] Keep custom report charts stable with long legends (#5394) (#8911)

Felipe Medicibc9bba67f306
diff --git a/packages/desktop-client/e2e/reports.test.ts b/packages/desktop-client/e2e/reports.test.ts
index 114e782085..6ac5d3ec76 100644
--- a/packages/desktop-client/e2e/reports.test.ts
+++ b/packages/desktop-client/e2e/reports.test.ts
@@ -166,6 +166,47 @@ test.describe('Reports', () => {
await customReportPage.showLegendButton.click();
});
+ ['Bar Graph', 'Line Graph'].forEach(graph => {
+ test(`${graph} keeps its height when the legend needs scrolling`, async () => {
+ await page.setViewportSize({ width: 1280, height: 700 });
+ await customReportPage.selectMode('time');
+ await customReportPage.selectViz(graph);
+ await page
+ .getByRole('button', { name: 'Options', exact: true })
+ .click();
+ await page
+ .getByRole('button', { name: 'Show empty rows', exact: true })
+ .click();
+ await page.keyboard.press('Escape');
+
+ const content = page.locator('#custom-report-content');
+ const chart = content.locator('.recharts-wrapper');
+ await expect(chart).toBeVisible();
+ const originalHeight = await chart.evaluate(el => el.clientHeight);
+
+ await customReportPage.showSummaryButton.click();
+ await customReportPage.showLegendButton.click();
+
+ await expect
+ .poll(() => chart.evaluate(el => el.clientHeight))
+ .toBe(originalHeight);
+ const legend = content
+ .getByText('Category', { exact: true })
+ .locator('..');
+ await expect
+ .poll(() => legend.evaluate(el => el.scrollHeight > el.clientHeight))
+ .toBe(true);
+ await legend.hover();
+ await page.mouse.wheel(0, 500);
+ await expect
+ .poll(() => legend.evaluate(el => el.scrollTop))
+ .toBeGreaterThan(0);
+ await expect
+ .poll(() => chart.evaluate(el => el.clientHeight))
+ .toBe(originalHeight);
+ });
+ });
+
test('Validates that "show summary" button shows the summary', async () => {
await customReportPage.selectViz('Bar Graph');
await customReportPage.showSummaryButton.click();
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index 73d23cf009..1b46836e3c 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -1001,7 +1001,7 @@ function CustomReportInner({
style={{
backgroundColor: theme.tableBackground,
flexDirection: 'row',
- flex: '1 0 auto',
+ flex: 1,
}}
>
<View
diff --git a/upcoming-release-notes/fix-custom-report-legend-scroll.md b/upcoming-release-notes/fix-custom-report-legend-scroll.md
new file mode 100644
index 0000000000..b9a0eda721
--- /dev/null
+++ b/upcoming-release-notes/fix-custom-report-legend-scroll.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [femedici]
+---
+
+Keep custom report charts at a stable height when scrolling a long legend.