From 4c389117b7aa7180278bbc3883d7a76d0afc487d Mon Sep 17 00:00:00 2001 From: Alessandro Date: Mon, 11 Aug 2025 13:02:16 +0200 Subject: [PATCH] allow null and correct behavior --- examples/react/src/examples/Edges/index.tsx | 40 ++++++++++++++++++- .../container/EdgeRenderer/MarkerSymbols.tsx | 4 +- packages/react/src/types/component-props.ts | 10 ++++- packages/system/src/types/edges.ts | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/examples/react/src/examples/Edges/index.tsx b/examples/react/src/examples/Edges/index.tsx index 8239f202..c4f9fb69 100644 --- a/examples/react/src/examples/Edges/index.tsx +++ b/examples/react/src/examples/Edges/index.tsx @@ -82,6 +82,18 @@ const initialNodes: Node[] = [ data: { label: 'Output 12' }, position: { x: 825, y: 300 }, }, + { + id: '13', + type: 'output', + data: { label: 'Output 13' }, + position: { x: 900, y: 200 }, + }, + { + id: '14', + type: 'output', + data: { label: 'Output 14' }, + position: { x: 825, y: 100 }, + }, ]; const initialEdges: Edge[] = [ @@ -211,7 +223,7 @@ const initialEdges: Edge[] = [ id: 'e4-12', source: '4', target: '12', - label: 'Marker No Prop Color (should use CSS variable)', + label: 'Marker explicitly undefined Color (defaults to none)', className: 'css-variable-edge', markerEnd: { type: MarkerType.ArrowClosed, @@ -220,6 +232,31 @@ const initialEdges: Edge[] = [ height: 40, }, }, + { + id: 'e4-13', + source: '4', + target: '13', + label: 'Marker null Color (should use `--xy-edge-stroke` CSS variable)', + className: 'css-variable-edge', + markerEnd: { + type: MarkerType.ArrowClosed, + color: null, + width: 40, + height: 40, + }, + }, + { + id: 'e4-14', + source: '4', + target: '14', + label: 'Marker implicitly undefined Color (defaults to defaultMarkerColor)', + className: 'css-variable-edge', + markerEnd: { + type: MarkerType.ArrowClosed, + width: 40, + height: 40, + }, + }, ]; const edgeTypes: EdgeTypes = { @@ -271,6 +308,7 @@ const EdgesFlow = () => { onEdgeMouseLeave={onEdgeMouseLeave} onDelete={console.log} defaultEdgeOptions={defaultEdgeOptions} + defaultMarkerColor={'purple'} > diff --git a/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx b/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx index 3321d4cd..089cda47 100644 --- a/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx +++ b/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx @@ -8,7 +8,7 @@ type SymbolProps = Omit; const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { const style = { strokeWidth, - ...(color && color !== 'none' && { stroke: color, fill: color }), + ...(color && { stroke: color }), }; return ; @@ -17,7 +17,7 @@ const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { const style = { strokeWidth, - ...(color && color !== 'none' && { stroke: color, fill: color }), + ...(color && { stroke: color, fill: color }), }; return ; diff --git a/packages/react/src/types/component-props.ts b/packages/react/src/types/component-props.ts index 16d4aa58..e0948739 100644 --- a/packages/react/src/types/component-props.ts +++ b/packages/react/src/types/component-props.ts @@ -139,7 +139,12 @@ export interface ReactFlowProps void; + onReconnectEnd?: ( + event: MouseEvent | TouchEvent, + edge: EdgeType, + handleType: HandleType, + connectionState: FinalConnectionState + ) => void; /** * Use this event handler to add interactivity to a controlled flow. * It is called on node drag, select, and move. @@ -494,9 +499,10 @@ export interface ReactFlowProps