diff --git a/Docs/Tasks.md b/Docs/Tasks.md index 29d1926..8fab49b 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -315,6 +315,8 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue. **Docs changes needed:** None. +**Status:** Completed. + **Why this is needed:** The architecture explicitly forbids building custom modal overlays ("Use Fluent UI `` for modals and confirmations — never build custom modal overlays"). Hand-built modals bypass Fluent UI's accessibility tree (focus trap, ARIA roles, portal rendering) and duplicate boilerplate that the library provides. A Fluent `` is keyboard-accessible, screen-reader-compatible, and inherits the theme automatically. --- diff --git a/frontend/src/components/ErrorBoundary.tsx b/frontend/src/components/ErrorBoundary.tsx index 98adc42..0d2a6db 100644 --- a/frontend/src/components/ErrorBoundary.tsx +++ b/frontend/src/components/ErrorBoundary.tsx @@ -4,6 +4,7 @@ * Catches render-time exceptions in child components and shows a fallback UI. */ import React from "react"; +import { Button, makeStyles, Text, tokens } from "@fluentui/react-components"; interface ErrorBoundaryState { hasError: boolean; @@ -14,11 +15,49 @@ interface ErrorBoundaryProps { children: React.ReactNode; } +interface ErrorBoundaryFallbackProps { + message: string; + onReload: () => void; +} + +const useFallbackStyles = makeStyles({ + root: { + display: "flex", + flexDirection: "column", + alignItems: "center", + justifyContent: "center", + minHeight: "100vh", + padding: tokens.spacingVerticalL, + textAlign: "center", + gap: tokens.spacingVerticalM, + }, + message: { + maxWidth: "40rem", + }, +}); + +function ErrorBoundaryFallback({ message, onReload }: ErrorBoundaryFallbackProps): React.ReactElement { + const styles = useFallbackStyles(); + + return ( +
+ + Something went wrong + + + {message} + + +
+ ); +} + export class ErrorBoundary extends React.Component { constructor(props: ErrorBoundaryProps) { super(props); this.state = { hasError: false, errorMessage: null }; - this.handleReload = this.handleReload.bind(this); } static getDerivedStateFromError(error: Error): ErrorBoundaryState { @@ -29,31 +68,17 @@ export class ErrorBoundary extends React.Component { window.location.reload(); - } + }; render(): React.ReactNode { if (this.state.hasError) { return ( -
-

Something went wrong

-

{this.state.errorMessage ?? "Please try reloading the page."}

- -
+ ); }