Skip to content

A local-first personal finance app

Improve crossover reloads (#8352)

Lucasc64c0aa049a9
diff --git a/packages/desktop-client/src/components/reports/reports/Crossover.tsx b/packages/desktop-client/src/components/reports/reports/Crossover.tsx
index 8f0e75a5ca..79ebb0a32f 100644
--- a/packages/desktop-client/src/components/reports/reports/Crossover.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Crossover.tsx
@@ -368,18 +368,27 @@ function CrossoverInner({ widget }: CrossoverInnerProps) {
);
const data = useReport<CrossoverData>('crossover', params);
+ const [previousData, setPreviousData] = useState<CrossoverData | null>(null);
+
+ useEffect(() => {
+ if (data) {
+ setPreviousData(data);
+ }
+ }, [data]);
+
+ const displayData = data ?? previousData;
// Get the default estimated return from the spreadsheet data
- const historicalReturn = data?.historicalReturn ?? null;
+ const historicalReturn = displayData?.historicalReturn ?? null;
// Get years to retire from spreadsheet data
- const yearsToRetire = data?.yearsToRetire ?? null;
+ const yearsToRetire = displayData?.yearsToRetire ?? null;
// Get target monthly income from spreadsheet data
- const targetMonthlyIncome = data?.targetMonthlyIncome ?? null;
+ const targetMonthlyIncome = displayData?.targetMonthlyIncome ?? null;
// Get target nest egg from spreadsheet data
- const targetNestEgg = data?.targetNestEgg ?? null;
+ const targetNestEgg = displayData?.targetNestEgg ?? null;
const navigate = useNavigate();
const { isNarrowWidth } = useResponsive();
@@ -412,7 +421,7 @@ function CrossoverInner({ widget }: CrossoverInnerProps) {
if (
!allMonths ||
- !data ||
+ !displayData ||
!start ||
!end ||
isCategoriesLoading ||
@@ -1120,7 +1129,7 @@ function CrossoverInner({ widget }: CrossoverInnerProps) {
}}
>
<CrossoverGraph
- graphData={data.graphData}
+ graphData={displayData.graphData}
style={{ height: '100%', flex: 1 }}
/>
</View>
diff --git a/upcoming-release-notes/8351.md b/upcoming-release-notes/8351.md
new file mode 100644
index 0000000000..ed958f7585
--- /dev/null
+++ b/upcoming-release-notes/8351.md
@@ -0,0 +1,6 @@
+---
+category: Bugfixes
+authors: [lucasboebel]
+---
+
+avoid the full-page reset and scroll jump when editing crossover report filters