Ensure step is selected after creation when a new version has to be created (#9218)

Fixes
https://discord.com/channels/1130383047699738754/1318606664202715156/1318606664202715156
This commit is contained in:
Baptiste Devessier
2024-12-24 14:43:10 +01:00
committed by GitHub
parent d2abd59a51
commit 4f329d6005
3 changed files with 34 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { getSnapshotValue } from '@/ui/utilities/state/utils/getSnapshotValue';
import { workflowDiagramState } from '@/workflow/states/workflowDiagramState';
import { workflowLastCreatedStepIdState } from '@/workflow/states/workflowLastCreatedStepIdState';
import {
WorkflowVersion,
WorkflowWithCurrentVersion,
@ -39,6 +40,26 @@ export const WorkflowDiagramEffect = ({
);
}
const lastCreatedStepId = getSnapshotValue(
snapshot,
workflowLastCreatedStepIdState,
);
if (isDefined(lastCreatedStepId)) {
mergedWorkflowDiagram.nodes = mergedWorkflowDiagram.nodes.map(
(node) => {
if (node.id === lastCreatedStepId) {
return {
...node,
selected: true,
};
}
return node;
},
);
set(workflowLastCreatedStepIdState, undefined);
}
set(workflowDiagramState, mergedWorkflowDiagram);
};
},