From a9a1316183847b32c7d9deea16807f8d7cc824ab Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 25 Oct 2023 13:50:43 -0300 Subject: [PATCH] chore(tabsContext.tsx): import cloneDeep function from lodash to improve code readability and maintainability fix(tabsContext.tsx): fix comment typo fix(tabsContext.tsx): add missing semicolon to improve code consistency fix(tabsContext.tsx): clone edge data object to prevent mutation of original object refactor(PageComponent/index.tsx): remove unnecessary comment --- src/frontend/src/contexts/tabsContext.tsx | 4 +++- .../src/pages/FlowPage/components/PageComponent/index.tsx | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 9e90b2212..cc4d691ac 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -1,5 +1,5 @@ import { AxiosError } from "axios"; -import _ from "lodash"; +import _, { cloneDeep } from "lodash"; import { ReactNode, createContext, @@ -428,6 +428,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { id: source, }); sourceHandleObject.id = source; + edge.data.sourceHandle = sourceHandleObject; const targetHandleObject: targetHandleType = scapeJSONParse( edge.targetHandle! @@ -452,6 +453,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { sourceHandle, targetHandle, id, + data: cloneDeep(edge.data), style: { stroke: "#555" }, className: targetHandleObject.type === "Text" diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index 20fb826e1..0512859c7 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -310,7 +310,6 @@ export default function Page({ event.dataTransfer.getData("nodedata") ); - // If data type is not "chatInput" or if there are no "chatInputNode" nodes present in the ReactFlow instance, create a new node // Calculate the position where the node should be created const position = reactFlowInstance!.project({ x: event.clientX - reactflowBounds!.left,