Skip to content

A local-first personal finance app

custom report clickthrough for category groups (#8391)

Matt Fiddaman9dbee1078a09
diff --git a/packages/desktop-client/index.html b/packages/desktop-client/index.html
index f5ddb679f7..71af8fac67 100644
--- a/packages/desktop-client/index.html
+++ b/packages/desktop-client/index.html
@@ -66,6 +66,15 @@
outline-color: #2b8fed;
}
+ /* recharts makes chart surfaces and layers focusable for keyboard
+ navigation; suppress the focus ring it would draw on click */
+ .recharts-wrapper:focus,
+ .recharts-wrapper :focus,
+ .recharts-surface:focus,
+ .recharts-surface :focus {
+ outline: none;
+ }
+
input,
textarea {
font-size: 1em;
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index e983de9247..2e07b346d0 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -318,8 +318,7 @@ export function BarGraph({
{...animationProps}
onMouseLeave={() => setPointer('')}
onMouseEnter={() =>
- !['Group', 'Interval'].includes(groupBy) &&
- setPointer('pointer')
+ groupBy !== 'Interval' && setPointer('pointer')
}
onClick={item => {
const itemPayload = hasUncategorizedId(item.payload)
@@ -328,7 +327,7 @@ export function BarGraph({
return (
((compact && showTooltip) || !compact) &&
- !['Group', 'Interval'].includes(groupBy) &&
+ groupBy !== 'Interval' &&
showActivity({
navigate,
categories,
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index 9a5ea04af6..0e9e434029 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -500,13 +500,6 @@ export function DonutGraph({
(canDeviceHover() || activeGroupIndex === index) &&
((compact && showTooltip) || !compact)
) {
- const groupCategoryIds = (
- data.groupedData?.find(g => g.id === item.id)
- ?.categories ?? []
- )
- .map(c => c.id)
- .filter((c): c is string => c != null);
-
showActivity({
navigate,
categories,
@@ -518,8 +511,9 @@ export function DonutGraph({
type: 'totals',
startDate: data.startDate,
endDate: data.endDate,
- field: 'category',
- id: groupCategoryIds,
+ field: 'group',
+ id: item.id,
+ uncategorizedId: item.uncategorizedId,
});
}
}}
@@ -669,7 +663,7 @@ export function DonutGraph({
onMouseEnter={(_, index) => {
if (canDeviceHover()) {
setActiveIndex(index);
- if (!['Group', 'Interval'].includes(groupBy)) {
+ if (groupBy !== 'Interval') {
setPointer('pointer');
}
}
@@ -679,20 +673,10 @@ export function DonutGraph({
setActiveIndex(index);
}
if (
- !['Interval'].includes(groupBy) &&
+ groupBy !== 'Interval' &&
(canDeviceHover() || activeIndex === index) &&
((compact && showTooltip) || !compact)
) {
- const groupCategoryIds =
- groupBy === 'Group'
- ? (
- categories.grouped.find(g => g.id === item.id)
- ?.categories ?? []
- )
- .map(c => c.id)
- .filter((c): c is string => c != null)
- : undefined;
-
showActivity({
navigate,
categories,
@@ -704,11 +688,9 @@ export function DonutGraph({
type: 'totals',
startDate: data.startDate,
endDate: data.endDate,
- field:
- groupBy === 'Group'
- ? 'category'
- : groupBy.toLowerCase(),
- id: groupBy === 'Group' ? groupCategoryIds : item.id,
+ field: groupBy.toLowerCase(),
+ id: item.id,
+ uncategorizedId: item.uncategorizedId,
});
}
}}
diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
index d7d4dee75f..a998728269 100644
--- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
@@ -285,7 +285,7 @@ export function LineGraph({
r: entry.dataKey === tooltip && !compact ? 8 : 3,
onMouseEnter: () => {
setTooltip(entry.dataKey);
- if (!['Group', 'Interval'].includes(groupBy)) {
+ if (groupBy !== 'Interval') {
setPointer('pointer');
}
},
@@ -295,7 +295,7 @@ export function LineGraph({
},
onClick: (e, payload) =>
((compact && showTooltip) || !compact) &&
- !['Group', 'Interval'].includes(groupBy) &&
+ groupBy !== 'Interval' &&
onShowActivity(
entry.id,
payload,
diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
index 43f8e88a1c..b17a5260f5 100644
--- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
@@ -293,13 +293,13 @@ export function StackedBarGraph({
}}
onMouseEnter={() => {
setTooltip(entry.dataKey);
- if (!['Group', 'Interval'].includes(groupBy)) {
+ if (groupBy !== 'Interval') {
setPointer('pointer');
}
}}
onClick={e =>
((compact && showTooltip) || !compact) &&
- !['Group', 'Interval'].includes(groupBy) &&
+ groupBy !== 'Interval' &&
showActivity({
navigate,
categories,
diff --git a/packages/desktop-client/src/components/reports/graphs/showActivity.test.ts b/packages/desktop-client/src/components/reports/graphs/showActivity.test.ts
index 1a8736bd32..352595869e 100644
--- a/packages/desktop-client/src/components/reports/graphs/showActivity.test.ts
+++ b/packages/desktop-client/src/components/reports/graphs/showActivity.test.ts
@@ -51,6 +51,63 @@ describe('showActivity', () => {
});
});
+ it('adds a category group filter when drilling down by group', () => {
+ const navigate = vi.fn();
+
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp: 'totalAssets',
+ filters: [],
+ showHiddenCategories: true,
+ showOffBudget: true,
+ type: 'totals',
+ startDate: '2026-05-24',
+ endDate: '2026-05-30',
+ field: 'group',
+ id: 'group-usual',
+ });
+
+ const [path, options] = navigate.mock.calls[0];
+
+ expect(path).toBe('/accounts');
+ expect(options.state.filterConditions).toContainEqual({
+ field: 'category_group',
+ op: 'is',
+ value: 'group-usual',
+ type: 'id',
+ });
+ });
+
+ it('omits the category group filter for the uncategorized group', () => {
+ const navigate = vi.fn();
+
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp: 'totalAssets',
+ filters: [],
+ showHiddenCategories: true,
+ showOffBudget: true,
+ type: 'totals',
+ startDate: '2026-05-24',
+ endDate: '2026-05-30',
+ field: 'group',
+ id: 'uncategorized',
+ uncategorizedId: 'all',
+ });
+
+ const [, options] = navigate.mock.calls[0];
+
+ expect(
+ options.state.filterConditions.filter((f: { field: string }) =>
+ ['category', 'category_group'].includes(f.field),
+ ),
+ ).toHaveLength(0);
+ });
+
it('keeps the category filter for regular categories', () => {
const navigate = vi.fn();
diff --git a/packages/desktop-client/src/components/reports/graphs/showActivity.ts b/packages/desktop-client/src/components/reports/graphs/showActivity.ts
index 88c6fcd032..86f27c588f 100644
--- a/packages/desktop-client/src/components/reports/graphs/showActivity.ts
+++ b/packages/desktop-client/src/components/reports/graphs/showActivity.ts
@@ -22,7 +22,7 @@ type showActivityProps = {
type: string;
startDate: string;
endDate?: string;
- field?: string;
+ field?: string; // 'group' becomes a category_group filter
id?: string | string[]; // changed: supports array for oneOf
uncategorizedId?: 'off_budget' | 'transfer' | 'other' | 'all';
interval?: string;
@@ -62,13 +62,21 @@ export function showActivity({
value: true,
type: 'boolean',
}
- : id && {
- // changed: use oneOf when id is an array, is when it's a string
- field,
- op: Array.isArray(id) ? 'oneOf' : 'is',
- value: id,
- type: 'id',
- };
+ : field === 'group'
+ ? !uncategorizedId &&
+ id && {
+ field: 'category_group',
+ op: 'is',
+ value: id,
+ type: 'id',
+ }
+ : id && {
+ // changed: use oneOf when id is an array, is when it's a string
+ field,
+ op: Array.isArray(id) ? 'oneOf' : 'is',
+ value: id,
+ type: 'id',
+ };
const filterConditions = [
...filters,
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index 32e0b22d0f..b5bf972136 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -76,25 +76,22 @@ export const ReportTableRow = memo(
const { data: categories = { grouped: [], list: [] } } = useCategories();
const { data: accounts = [] } = useAccounts();
- const pointer =
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id)
- ? 'pointer'
- : 'inherit';
+ const isGroupRow =
+ item.uncategorizedId === 'all' ||
+ categories.grouped.some(g => g.id === item.id);
+ const drilldownField = isGroupRow ? 'group' : groupBy.toLowerCase();
+ const canShowActivity =
+ !isNarrowWidth && groupBy !== 'Interval' && !compact;
- const hoverUnderline =
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id)
- ? {
- cursor: pointer,
- ':hover': { textDecoration: 'underline' },
- flexGrow: 0,
- }
- : {};
+ const pointer = canShowActivity ? 'pointer' : 'inherit';
+
+ const hoverUnderline = canShowActivity
+ ? {
+ cursor: pointer,
+ ':hover': { textDecoration: 'underline' },
+ flexGrow: 0,
+ }
+ : {};
return (
<Row
@@ -161,10 +158,7 @@ export const ReportTableRow = memo(
: undefined
}
onClick={() =>
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id) &&
+ canShowActivity &&
showActivity({
navigate,
categories,
@@ -176,7 +170,7 @@ export const ReportTableRow = memo(
type: 'time',
startDate: intervalItem.intervalStartDate || '',
endDate: intervalItem.intervalEndDate || '',
- field: groupBy.toLowerCase(),
+ field: drilldownField,
id: item.id,
uncategorizedId: item.uncategorizedId,
interval,
@@ -219,10 +213,7 @@ export const ReportTableRow = memo(
)}
valueStyle={compactStyle}
onClick={() =>
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id) &&
+ canShowActivity &&
showActivity({
navigate,
categories,
@@ -234,7 +225,7 @@ export const ReportTableRow = memo(
type: 'assets',
startDate,
endDate,
- field: groupBy.toLowerCase(),
+ field: drilldownField,
id: item.id,
uncategorizedId: item.uncategorizedId,
})
@@ -270,10 +261,7 @@ export const ReportTableRow = memo(
)}
valueStyle={compactStyle}
onClick={() =>
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id) &&
+ canShowActivity &&
showActivity({
navigate,
categories,
@@ -285,7 +273,7 @@ export const ReportTableRow = memo(
type: 'debts',
startDate,
endDate,
- field: groupBy.toLowerCase(),
+ field: drilldownField,
id: item.id,
uncategorizedId: item.uncategorizedId,
})
@@ -320,10 +308,7 @@ export const ReportTableRow = memo(
)}
valueStyle={compactStyle}
onClick={() =>
- !isNarrowWidth &&
- !['Group', 'Interval'].includes(groupBy) &&
- !compact &&
- !categories.grouped.map(g => g.id).includes(item.id) &&
+ canShowActivity &&
showActivity({
navigate,
categories,
@@ -335,7 +320,7 @@ export const ReportTableRow = memo(
type: 'totals',
startDate,
endDate,
- field: groupBy.toLowerCase(),
+ field: drilldownField,
id: item.id,
uncategorizedId: item.uncategorizedId,
})
diff --git a/upcoming-release-notes/report-group-clickthrough.md b/upcoming-release-notes/report-group-clickthrough.md
new file mode 100644
index 0000000000..e25ee30caa
--- /dev/null
+++ b/upcoming-release-notes/report-group-clickthrough.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [matt-fidd]
+---
+
+Support clicking on category groups in reports to see the filtered transactions