From 8d910c7f34a36e73e50569526c5e64e2ab4b9b26 Mon Sep 17 00:00:00 2001 From: woo0ood Date: Sun, 26 Jan 2025 06:08:01 +0000 Subject: [PATCH] fix: prevent Loop and Iteration nodes from nesting within each other. --- web/app/components/workflow/hooks/use-nodes-data.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/hooks/use-nodes-data.ts b/web/app/components/workflow/hooks/use-nodes-data.ts index cece339fc4..c68ce92e34 100644 --- a/web/app/components/workflow/hooks/use-nodes-data.ts +++ b/web/app/components/workflow/hooks/use-nodes-data.ts @@ -48,17 +48,19 @@ export const useAvailableBlocks = (nodeType?: BlockEnum, isInIteration?: boolean return useMemo(() => { return { availablePrevBlocks: availablePrevBlocks.filter((nType) => { - if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.End)) + if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) return false - if (isInLoop && (nType === BlockEnum.Loop || nType === BlockEnum.End)) + + if (isInLoop && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) return false return true }), availableNextBlocks: availableNextBlocks.filter((nType) => { - if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.End)) + if (isInIteration && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) return false - if (isInLoop && (nType === BlockEnum.Loop || nType === BlockEnum.End)) + + if (isInLoop && (nType === BlockEnum.Iteration || nType === BlockEnum.Loop || nType === BlockEnum.End)) return false return true