From 74d30075f207395086cbe2ba9cd34e0073979059 Mon Sep 17 00:00:00 2001 From: Matthew Runyon Date: Wed, 31 Jan 2024 14:12:41 -0600 Subject: [PATCH] feat(ui): Add error boundary to prevent UI crashing due to rendering errors (#245) This should prevent the whole UI from going blank if there's a rendering error in JS. An example dashboard that would crash the whole UI previously is provided below. Now you get an error message and can still go back to your code studio. ```py from deephaven import ui @ui.component def Foo(): return [ ui.row(ui.stack(ui.panel(ui.text('Foo')))), ui.row(ui.stack(ui.panel(ui.text('Bar')))) ] f = ui.dashboard(Foo()) ``` --- plugins/ui/src/js/src/DashboardPlugin.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/ui/src/js/src/DashboardPlugin.tsx b/plugins/ui/src/js/src/DashboardPlugin.tsx index 338ea88de..9a62124c8 100644 --- a/plugins/ui/src/js/src/DashboardPlugin.tsx +++ b/plugins/ui/src/js/src/DashboardPlugin.tsx @@ -13,6 +13,7 @@ import { useConnection } from '@deephaven/jsapi-components'; import { DeferredApiBootstrap } from '@deephaven/jsapi-bootstrap'; import { Widget } from '@deephaven/jsapi-types'; import type { VariableDefinition } from '@deephaven/jsapi-types'; +import { ErrorBoundary } from '@deephaven/components'; import styles from './styles.scss?inline'; import { WidgetWrapper } from './WidgetTypes'; import PortalPanel from './PortalPanel'; @@ -204,9 +205,11 @@ export function DashboardPlugin({ const widgetHandlers = useMemo( () => [...widgetMap.entries()].map(([widgetId, widget]) => ( - - - + + + + + )), [handleWidgetClose, widgetMap] );