From ff3622878c2ff92057b89730064057370fec91c7 Mon Sep 17 00:00:00 2001 From: andreastanderen Date: Fri, 27 Dec 2024 15:06:48 +0100 Subject: [PATCH] use ref for layoutsets to ensure updated layoutsets is passed to onProcessTaskRemove --- .../features/processEditor/ProcessEditor.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/app-development/features/processEditor/ProcessEditor.tsx b/frontend/app-development/features/processEditor/ProcessEditor.tsx index 8b8e407559f..1f81594eefb 100644 --- a/frontend/app-development/features/processEditor/ProcessEditor.tsx +++ b/frontend/app-development/features/processEditor/ProcessEditor.tsx @@ -23,6 +23,7 @@ import { useAppPolicyQuery } from '../../hooks/queries'; import type { OnProcessTaskEvent } from '@altinn/process-editor/types/OnProcessTask'; import { OnProcessTaskAddHandler } from './handlers/OnProcessTaskAddHandler'; import { OnProcessTaskRemoveHandler } from './handlers/OnProcessTaskRemoveHandler'; +import type { LayoutSets } from 'app-shared/types/api/LayoutSetsResponse'; export const ProcessEditor = (): React.ReactElement => { const { t } = useTranslation(); @@ -60,6 +61,11 @@ export const ProcessEditor = (): React.ReactElement => { false, ); const { data: layoutSets } = useLayoutSetsQuery(org, app); + const layoutSetsRef = React.useRef(layoutSets); + + React.useEffect(() => { + layoutSetsRef.current = layoutSets; + }, [layoutSets]); const pendingApiOperations: boolean = mutateBpmnPending || @@ -104,7 +110,7 @@ export const ProcessEditor = (): React.ReactElement => { org, app, currentPolicy, - layoutSets, + layoutSetsRef.current, mutateApplicationPolicy, deleteDataTypeFromAppMetadata, deleteLayoutSet, @@ -121,7 +127,7 @@ export const ProcessEditor = (): React.ReactElement => { availableDataTypeIds={appMetadata?.dataTypes?.map((dataType) => dataType.id)} availableDataModelIds={availableDataModelIds} allDataModelIds={allDataModelIds} - layoutSets={layoutSets} + layoutSets={layoutSetsRef.current} pendingApiOperations={pendingApiOperations} existingCustomReceiptLayoutSetId={existingCustomReceiptId} addLayoutSet={addLayoutSet}