Commit fc6f28f2 by Archer Committed by GitHub

fix: variables check (#2849)

* fix: variables check

* remove log
parent d4b99ddc
...@@ -298,7 +298,8 @@ export const formatEditorVariablePickerIcon = ( ...@@ -298,7 +298,8 @@ export const formatEditorVariablePickerIcon = (
}; };
export const isReferenceValue = (value: any, nodeIds: string[]): boolean => { export const isReferenceValue = (value: any, nodeIds: string[]): boolean => {
return Array.isArray(value) && value.length === 2 && nodeIds.includes(value[0]); const validIdList = [VARIABLE_NODE_ID, ...nodeIds];
return Array.isArray(value) && value.length === 2 && validIdList.includes(value[0]);
}; };
export const getElseIFLabel = (i: number) => { export const getElseIFLabel = (i: number) => {
......
...@@ -423,8 +423,8 @@ export const useWorkflow = () => { ...@@ -423,8 +423,8 @@ export const useWorkflow = () => {
} }
// If the node has child nodes, remove the child nodes // If the node has child nodes, remove the child nodes
if (nodes.some((n) => n.data.parentNodeId === node.id)) {
const childNodes = nodes.filter((n) => n.data.parentNodeId === node.id); const childNodes = nodes.filter((n) => n.data.parentNodeId === node.id);
if (childNodes.length > 0) {
const childNodeIds = childNodes.map((n) => n.id); const childNodeIds = childNodes.map((n) => n.id);
const childNodesChange = childNodes.map((node) => ({ const childNodesChange = childNodes.map((node) => ({
...change, ...change,
...@@ -440,14 +440,14 @@ export const useWorkflow = () => { ...@@ -440,14 +440,14 @@ export const useWorkflow = () => {
!childNodeIds.includes(edge.target) !childNodeIds.includes(edge.target)
) )
); );
return;
} }
setEdges((state) => setEdges((state) =>
state.filter((edge) => edge.source !== change.id && edge.target !== change.id) state.filter((edge) => edge.source !== change.id && edge.target !== change.id)
); );
onNodesChange([change]);
return true; return;
}); });
const handleSelectNode = useMemoizedFn((change: NodeSelectionChange) => { const handleSelectNode = useMemoizedFn((change: NodeSelectionChange) => {
// If the node is not selected and the Ctrl key is pressed, select the node // If the node is not selected and the Ctrl key is pressed, select the node
...@@ -517,9 +517,8 @@ export const useWorkflow = () => { ...@@ -517,9 +517,8 @@ export const useWorkflow = () => {
if (change.type === 'remove') { if (change.type === 'remove') {
const node = nodes.find((n) => n.id === change.id); const node = nodes.find((n) => n.id === change.id);
// 如果删除失败,则不继续执行 // 如果删除失败,则不继续执行
if (node && !handleRemoveNode(change, node)) { node && handleRemoveNode(change, node);
return; return;
}
} else if (change.type === 'select') { } else if (change.type === 'select') {
handleSelectNode(change); handleSelectNode(change);
} else if (change.type === 'position') { } else if (change.type === 'position') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment