diff --git a/designer/client/src/components/graph/utils/fragmentSchemaAligner.ts b/designer/client/src/components/graph/utils/fragmentSchemaAligner.ts index aebb0a6ebdb..bb9edfed421 100644 --- a/designer/client/src/components/graph/utils/fragmentSchemaAligner.ts +++ b/designer/client/src/components/graph/utils/fragmentSchemaAligner.ts @@ -1,13 +1,19 @@ import fp from "lodash/fp"; import { NodeType, ProcessDefinitionData } from "../../../types"; +/* + * TODO: It's a workaround + * There may be situations where an open scenario has its fragment parameters edited by a different owner + * In such cases, we need to align the fragmentInput properties with the updated state of the fragment process definition data. + */ export function alignFragmentWithSchema(processDefinitionData: ProcessDefinitionData, fragmentNode: NodeType) { const fragmentId = fragmentNode.ref.id; const fragmentSchema = processDefinitionData.componentGroups - .find((componentGroups) => { - return componentGroups.name === "fragments"; - }) - .components.find((obj) => obj.node.ref.id === fragmentId); + // This is a workaround. We cannot look for the fragment schema only in the fragments group, + // because fragmentInput can be moved to a different group. + // In this case, there was an error, which is why we need to iterate through all groups. + .flatMap((componentGroups) => componentGroups.components) + .find((obj) => obj?.node?.ref?.id === fragmentId); const fragmentSchemaParameters = fragmentSchema.node.ref.parameters; const mergedParameters = fragmentSchemaParameters.map( (param) => fragmentNode.ref.parameters.find((nodeParam) => nodeParam.name === param.name) || param,