From 4d6c6ffc7d852d06b4af9b7a057224ad0e00a049 Mon Sep 17 00:00:00 2001 From: Andreas Schultz Date: Mon, 11 Apr 2022 07:39:22 +0200 Subject: [PATCH] Also add 'handleType' parameter to 'onEdgeUpdateEnd' callback analogous to 'onEdgeUpdateStart' --- example/src/UpdatableEdge/index.tsx | 5 +++-- src/components/Edges/wrapEdge.tsx | 2 +- src/container/EdgeRenderer/index.tsx | 2 +- src/container/ReactFlow/index.tsx | 2 +- src/types/index.ts | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/example/src/UpdatableEdge/index.tsx b/example/src/UpdatableEdge/index.tsx index 4ffdab04..3c1fdb84 100644 --- a/example/src/UpdatableEdge/index.tsx +++ b/example/src/UpdatableEdge/index.tsx @@ -9,6 +9,7 @@ import ReactFlow, { Edge, removeElements, } from 'react-flow-renderer'; +import {HandleType} from "../../../dist"; const initialElements: Elements = [ { @@ -50,8 +51,8 @@ const initialElements: Elements = [ ]; const onLoad = (reactFlowInstance: OnLoadParams) => reactFlowInstance.fitView(); -const onEdgeUpdateStart = (_: React.MouseEvent, edge: Edge) => console.log('start update', edge); -const onEdgeUpdateEnd = (_: MouseEvent, edge: Edge) => console.log('end update', edge); +const onEdgeUpdateStart = (_: React.MouseEvent, edge: Edge, handleType: HandleType) => console.log(`start update ${handleType} handle`, edge); +const onEdgeUpdateEnd = (_: MouseEvent, edge: Edge, handleType: HandleType) => console.log(`end update ${handleType} handle`, edge); const UpdatableEdge = () => { const [elements, setElements] = useState(initialElements); diff --git a/src/components/Edges/wrapEdge.tsx b/src/components/Edges/wrapEdge.tsx index 2cad3166..caa877d6 100644 --- a/src/components/Edges/wrapEdge.tsx +++ b/src/components/Edges/wrapEdge.tsx @@ -144,7 +144,7 @@ export default (EdgeComponent: ComponentType) => { onEdgeUpdateStart?.(event, edgeElement, handleType); const _onEdgeUpdate = onEdgeUpdateEnd - ? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement) + ? (evt: MouseEvent): void => onEdgeUpdateEnd(evt, edgeElement, handleType) : undefined; onMouseDown( diff --git a/src/container/EdgeRenderer/index.tsx b/src/container/EdgeRenderer/index.tsx index dde5a2fa..303441b6 100644 --- a/src/container/EdgeRenderer/index.tsx +++ b/src/container/EdgeRenderer/index.tsx @@ -36,7 +36,7 @@ interface EdgeRendererProps { onEdgeMouseMove?: (event: React.MouseEvent, edge: Edge) => void; onEdgeMouseLeave?: (event: React.MouseEvent, edge: Edge) => void; onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, handleType: HandleType) => void; - onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void; + onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge, handleType: HandleType) => void; edgeUpdaterRadius?: number; } diff --git a/src/container/ReactFlow/index.tsx b/src/container/ReactFlow/index.tsx index 96c27fcd..0532f21b 100644 --- a/src/container/ReactFlow/index.tsx +++ b/src/container/ReactFlow/index.tsx @@ -125,7 +125,7 @@ export interface ReactFlowProps extends Omit, 'on onEdgeMouseLeave?: (event: ReactMouseEvent, edge: Edge) => void; onEdgeDoubleClick?: (event: ReactMouseEvent, edge: Edge) => void; onEdgeUpdateStart?: (event: ReactMouseEvent, edge: Edge, handleType: HandleType) => void; - onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void; + onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge, handleType: HandleType) => void; edgeUpdaterRadius?: number; nodeTypesId?: string; edgeTypesId?: string; diff --git a/src/types/index.ts b/src/types/index.ts index c7fe2b7f..43aff734 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -133,7 +133,7 @@ export interface WrapEdgeProps { onMouseLeave?: (event: React.MouseEvent, edge: Edge) => void; edgeUpdaterRadius?: number; onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, handleType: HandleType) => void; - onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void; + onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge, handleType: HandleType) => void; } export interface EdgeProps {