A local-first personal finance app
Add ErrorBoundary around Modals and updating FatalError modal behavior. (#5649)
Matiss Janis Aboltinsb399f290a647
diff --git a/.cursor/rules/typescript.mdc b/.cursor/rules/typescript.mdcindex ccf11590eb..661f3e46c0 100644--- a/.cursor/rules/typescript.mdc+++ b/.cursor/rules/typescript.mdc@@ -13,6 +13,7 @@ Code Style and Structure- Prefer iteration and modularization over code duplication.- Use descriptive variable names with auxiliary verbs (e.g., isLoaded, hasError).- Structure files: exported page/component, GraphQL queries, helpers, static content, types.+- When creating a new component, place it in its own file rather than grouping multiple components in a single file.Naming Conventionsdiff --git a/packages/desktop-client/src/components/App.tsx b/packages/desktop-client/src/components/App.tsxindex dedb6bbfd0..be885168d0 100644--- a/packages/desktop-client/src/components/App.tsx+++ b/packages/desktop-client/src/components/App.tsx@@ -242,7 +242,9 @@ export function App() {<AppInner /></ErrorBoundary><ThemeStyle />- <Modals />+ <ErrorBoundary FallbackComponent={FatalError}>+ <Modals />+ </ErrorBoundary><UpdateNotification /></View></View>diff --git a/packages/desktop-client/src/components/FatalError.tsx b/packages/desktop-client/src/components/FatalError.tsxindex 0f80a80847..f8e1fcf605 100644--- a/packages/desktop-client/src/components/FatalError.tsx+++ b/packages/desktop-client/src/components/FatalError.tsx@@ -14,6 +14,8 @@ import { Link } from './common/Link';import { Modal, ModalHeader } from './common/Modal';import { Checkbox } from './forms';+import { useModalState } from '@desktop-client/hooks/useModalState';+type AppError = Error & {type?: string;IDBFailure?: boolean;@@ -194,13 +196,16 @@ function SharedArrayBufferOverride() {export function FatalError({ error }: FatalErrorProps) {const { t } = useTranslation();+ const { modalStack } = useModalState();+ const lastModal = modalStack[modalStack.length - 1];+const [showError, setShowError] = useState(false);const showSimpleRender = 'type' in error && error.type === 'app-init-failure';const isLazyLoadError = error instanceof LazyLoadFailedError;return (- <Modal name="fatal-error" isDismissable={false}>+ <Modal name={lastModal?.name ?? 'fatal-error'} isDismissable={false}><ModalHeadertitle={isLazyLoadError ? t('Loading Error') : t('Fatal Error')}/>diff --git a/upcoming-release-notes/5649.md b/upcoming-release-notes/5649.mdnew file mode 100644index 0000000000..aad14df9a4--- /dev/null+++ b/upcoming-release-notes/5649.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MatissJanis]+---++Add error boundary for modal windows