diff --git a/frontend/src/components/workflow/ConditionEdge.tsx b/frontend/src/components/workflow/ConditionEdge.tsx index fb7e4d0..cc1807c 100644 --- a/frontend/src/components/workflow/ConditionEdge.tsx +++ b/frontend/src/components/workflow/ConditionEdge.tsx @@ -9,10 +9,9 @@ import { EdgeLabelRenderer, getBezierPath, type EdgeProps, - useReactFlow, } from "@xyflow/react"; -import { Pencil, Trash2 } from "lucide-react"; -import { useContext, useState } from "react"; +import { Trash2 } from "lucide-react"; +import { useContext } from "react"; import { cn } from "@/lib/utils"; import { EdgeActionContext } from "./context"; @@ -29,12 +28,7 @@ export function ConditionEdge({ selected, }: EdgeProps) { const actions = useContext(EdgeActionContext); - const { setEdges } = useReactFlow(); - const [hovered, setHovered] = useState(false); - // 点击标签:只选中这条边(露出编辑/删除按钮),不直接进入编辑。 - const selectThisEdge = () => - setEdges((eds) => eds.map((e) => ({ ...e, selected: e.id === id }))); const [path, labelX, labelY] = getBezierPath({ sourceX, sourceY, @@ -55,7 +49,6 @@ export function ConditionEdge({ ? "表达式" : "默认路径") ).toString().trim(); - const expanded = hovered || selected; return ( <> @@ -70,16 +63,15 @@ export function ConditionEdge({ />
setHovered(true)} - onMouseLeave={() => setHovered(false)} > - {expanded && ( - - )} - {expanded && ( - - )} +
diff --git a/frontend/src/components/workflow/WorkflowCanvas.tsx b/frontend/src/components/workflow/WorkflowCanvas.tsx index 66b6950..708494f 100644 --- a/frontend/src/components/workflow/WorkflowCanvas.tsx +++ b/frontend/src/components/workflow/WorkflowCanvas.tsx @@ -552,6 +552,7 @@ export function WorkflowCanvas({ onEdgesChange={onEdgesChange} onConnect={onConnect} onConnectEnd={onConnectEnd} + onEdgeClick={(_, edge) => edgeActions.edit(edge.id)} isValidConnection={isValidConnection} onPaneClick={() => { onEditingEdgeIdChange(null);