A local-first personal finance app
prevent reports from unmounting when out of viewport (#6194)
Matt Fiddaman7e34ddd3566c
diff --git a/packages/desktop-client/src/components/reports/ReportCard.tsx b/packages/desktop-client/src/components/reports/ReportCard.tsxindex 16a022d401..c9e31ffc15 100644--- a/packages/desktop-client/src/components/reports/ReportCard.tsx+++ b/packages/desktop-client/src/components/reports/ReportCard.tsx@@ -1,5 +1,7 @@import React, {+ useEffect,useRef,+ useState,type ComponentProps,type ReactNode,type CSSProperties,@@ -43,12 +45,19 @@ export function ReportCard({}: ReportCardProps) {const ref = useRef(null);const isInViewport = useIsInViewport(ref);+ const [hasRendered, setHasRendered] = useState(false);const navigate = useNavigate();const { isNarrowWidth } = useResponsive();const containerProps = {flex: isNarrowWidth ? '1 1' : `0 0 calc(${size * 100}% / 3 - 20px)`,};+ useEffect(() => {+ if (isInViewport && !hasRendered) {+ setHasRendered(true);+ }+ }, [isInViewport, hasRendered]);+const layoutProps = {isEditing,menuItems,@@ -91,7 +100,7 @@ export function ReportCard({{/* we render the content only if it is in the viewportthis reduces the amount of concurrent server api calls and thushas a better performance */}- {isInViewport ? children : null}+ {isInViewport || hasRendered ? children : null}</View>);diff --git a/upcoming-release-notes/6194.md b/upcoming-release-notes/6194.mdnew file mode 100644index 0000000000..6ff0ab3d7d--- /dev/null+++ b/upcoming-release-notes/6194.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [matt-fidd]+---++Prevent reports from rerendering when re-entering the viewport