Skip to content

Commit

Permalink
fix(canvas): Refersh canvas after error
Browse files Browse the repository at this point in the history
Currently, if there's an error during a flow parsing, an error message is shown to the user to explain what happens and suggest checking the source code. In the VSCode extension, the canvas doesn't refresh after an error, causing the editor to be stuck until the user closes the extension and reopens it again or switches to another tab.

This commit addresses this issue by assigning a `key` property to the error boundary component, so it gets refreshed after an entity update that happens only after editing the source code.

fix: #714
  • Loading branch information
lordrip committed Jan 24, 2024
1 parent 16060a2 commit 650e703
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ui/src/components/Visualization/Visualization.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FunctionComponent, PropsWithChildren, ReactNode } from 'react';
import { FunctionComponent, PropsWithChildren, ReactNode, useMemo } from 'react';
import { BaseVisualCamelEntity } from '../../models/visualization/base-visual-entity';
import { ErrorBoundary } from '../ErrorBoundary';
import { Canvas } from './Canvas';
Expand All @@ -13,9 +13,11 @@ interface CanvasProps {
}

export const Visualization: FunctionComponent<PropsWithChildren<CanvasProps>> = (props) => {
const lastUpdate = useMemo(() => Date.now(), [props.entities]);

return (
<div className={`canvas-surface ${props.className ?? ''}`}>
<ErrorBoundary fallback={props.fallback ?? <CanvasFallback />}>
<ErrorBoundary key={lastUpdate} fallback={props.fallback ?? <CanvasFallback />}>
<Canvas contextToolbar={<ContextToolbar />} entities={props.entities} />
</ErrorBoundary>
</div>
Expand Down

0 comments on commit 650e703

Please sign in to comment.