mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
Add ErrorBoundary around Modals and updating FatalError modal behavior. (#5649)
Fix #4703
This commit is contained in:
committed by
GitHub
parent
7c07295448
commit
b399f290a6
@@ -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 Conventions
|
||||
|
||||
|
||||
@@ -242,7 +242,9 @@ export function App() {
|
||||
<AppInner />
|
||||
</ErrorBoundary>
|
||||
<ThemeStyle />
|
||||
<Modals />
|
||||
<ErrorBoundary FallbackComponent={FatalError}>
|
||||
<Modals />
|
||||
</ErrorBoundary>
|
||||
<UpdateNotification />
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -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}>
|
||||
<ModalHeader
|
||||
title={isLazyLoadError ? t('Loading Error') : t('Fatal Error')}
|
||||
/>
|
||||
|
||||
6
upcoming-release-notes/5649.md
Normal file
6
upcoming-release-notes/5649.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
Add error boundary for modal windows
|
||||
Reference in New Issue
Block a user