Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `<Tooltip />`
- prove useage of `usePlaceholder` by jest test coverage

### Changed

- `<EdgeDefaultV12 />`
- introduced the new `arrowDirection` property, replacing the previous `inversePath` to provide more flexible control over edge arrows, including support for bidirectional edges

## [24.4.1] - 2025-08-25

### Fixed
Expand Down
31 changes: 24 additions & 7 deletions src/extensions/react-flow/edges/EdgeDefaultV12.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ export type EdgeDefaultV12DataProps = Record<string, unknown> & {
* Size of the "glow" effect when the edge is hovered.
*/
pathGlowWidth?: number;
/*
* Direction of the SVG path is inversed.
* This is important for the placement of the markers and the animation movement.
/**
* Controls where arrow heads appear on the edge.
* - `normal`: arrow at the end (target)
* - `inversed`: arrow at the start (source)
* - `bidirectional`: arrows at both start and end
*/
inversePath?: boolean;
arrowDirection?: "normal" | "inversed" | "bidirectional";
/**
* Callback handler that returns a React element used as edge title.
*/
Expand Down Expand Up @@ -64,7 +66,15 @@ export const EdgeDefaultV12 = memo(
data = {},
...edgeOriginalProperties
}: EdgeProps<Edge<EdgeDefaultV12DataProps>>) => {
const { pathGlowWidth = 10, highlightColor, renderLabel, edgeSvgProps, intent, inversePath, strokeType } = data;
const {
pathGlowWidth = 10,
highlightColor,
renderLabel,
edgeSvgProps,
intent,
strokeType,
arrowDirection = "normal",
} = data;

const [edgePath, labelX, labelY] = getBezierPath({
sourceX,
Expand Down Expand Up @@ -103,6 +113,13 @@ export const EdgeDefaultV12 = memo(
/>
) : null);

const markerStart =
arrowDirection === "inversed" || arrowDirection === "bidirectional"
? "url(#arrow-closed-reverse)"
: undefined;
const markerEnd =
arrowDirection === "normal" || arrowDirection === "bidirectional" ? "url(#arrow-closed)" : undefined;

return (
<g
className={
Expand Down Expand Up @@ -136,8 +153,8 @@ export const EdgeDefaultV12 = memo(
<BaseEdge
id={id}
path={edgePath}
markerStart={inversePath ? "url(#arrow-closed-reverse)" : undefined}
markerEnd={!inversePath ? "url(#arrow-closed)" : undefined}
markerStart={markerStart}
markerEnd={markerEnd}
className={edgeDefaultUtils.createEdgeDefaultClassName({ strokeType })}
interactionWidth={pathGlowWidth}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ InverseEdge.args = {
...Default.args,
id: "inverse",
data: {
inversePath: true,
arrowDirection: "inversed",
},
};

export const Bidirectional = Template.bind({});
Bidirectional.args = {
...Default.args,
id: "bidirectional",
data: {
arrowDirection: "bidirectional",
},
};

Expand Down