Skip to content

A local-first personal finance app

[Mobile] 🐛 Fix viewing pie/donut charts on mobile (#4935)

OhNoBigO4f6b97ae4a7c
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index 4574314899..4a7ad9c05f 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -24,6 +24,8 @@ import { useNavigate } from '@desktop-client/hooks/useNavigate';
const RADIAN = Math.PI / 180;
+const canDeviceHover = () => window.matchMedia('(hover: hover)').matches;
+
const ActiveShapeMobile = props => {
const {
cx,
@@ -280,29 +282,39 @@ export function DonutGraph({
endAngle={-270}
onMouseLeave={() => setPointer('')}
onMouseEnter={(_, index) => {
- setActiveIndex(index);
- if (!['Group', 'Interval'].includes(groupBy)) {
- setPointer('pointer');
+ if (canDeviceHover()) {
+ setActiveIndex(index);
+ if (!['Group', 'Interval'].includes(groupBy)) {
+ setPointer('pointer');
+ }
+ }
+ }}
+ onClick={(item, index) => {
+ if (!canDeviceHover()) {
+ setActiveIndex(index);
+ }
+
+ if (
+ !['Group', 'Interval'].includes(groupBy) &&
+ (canDeviceHover() || activeIndex === index) &&
+ ((compact && showTooltip) || !compact)
+ ) {
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp,
+ filters,
+ showHiddenCategories,
+ showOffBudget,
+ type: 'totals',
+ startDate: data.startDate,
+ endDate: data.endDate,
+ field: groupBy.toLowerCase(),
+ id: item.id,
+ });
}
}}
- onClick={item =>
- ((compact && showTooltip) || !compact) &&
- !['Group', 'Interval'].includes(groupBy) &&
- showActivity({
- navigate,
- categories,
- accounts,
- balanceTypeOp,
- filters,
- showHiddenCategories,
- showOffBudget,
- type: 'totals',
- startDate: data.startDate,
- endDate: data.endDate,
- field: groupBy.toLowerCase(),
- id: item.id,
- })
- }
>
{data.legend.map((entry, index) => (
<Cell key={`cell-${index}`} fill={entry.color} />
diff --git a/upcoming-release-notes/4935.md b/upcoming-release-notes/4935.md
new file mode 100644
index 0000000000..5952ddaa92
--- /dev/null
+++ b/upcoming-release-notes/4935.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [ohNoBigO]
+---
+
+Fix viewing pie/donut charts on mobile