Merge pull request #5459 from xyflow/arrow-closed-fix

Fix open arrow marker using fill color from edge instead of none
This commit is contained in:
Moritz Klack
2025-08-18 21:07:34 +02:00
committed by GitHub
6 changed files with 37 additions and 11 deletions

View File

@@ -0,0 +1,6 @@
---
'@xyflow/react': patch
'@xyflow/svelte': patch
---
Fix open arrow marker using fill color from edge instead of none

View File

@@ -267,7 +267,7 @@ const edgeTypes: EdgeTypes = {
const defaultEdgeOptions = {
markerEnd: {
type: MarkerType.ArrowClosed,
type: MarkerType.Arrow,
color: 'red',
width: 20,
height: 20,

View File

@@ -216,7 +216,7 @@
const defaultEdgeOptions = {
markerEnd: {
type: MarkerType.ArrowClosed,
type: MarkerType.Arrow,
color: 'red',
width: 20,
height: 20

View File

@@ -11,7 +11,16 @@ const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => {
...(color && { stroke: color }),
};
return <polyline style={style} strokeLinecap="round" strokeLinejoin="round" fill="none" points="-5,-4 0,0 -5,4" />;
return (
<polyline
className="arrow"
style={style}
strokeLinecap="round"
fill="none"
strokeLinejoin="round"
points="-5,-4 0,0 -5,4"
/>
);
};
const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => {
@@ -20,7 +29,15 @@ const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) =>
...(color && { stroke: color, fill: color }),
};
return <polyline style={style} strokeLinecap="round" strokeLinejoin="round" points="-5,-4 0,0 -5,4 -5,-4" />;
return (
<polyline
className="arrowclosed"
style={style}
strokeLinecap="round"
strokeLinejoin="round"
points="-5,-4 0,0 -5,4 -5,-4"
/>
);
};
export const MarkerSymbols = {

View File

@@ -11,9 +11,6 @@
color = 'none',
strokeWidth
}: MarkerProps = $props();
// Create inline styles when explicit color is provided
const polylineStyle = color ? `stroke: ${color}; fill: ${color};` : '';
</script>
<marker
@@ -29,16 +26,19 @@
>
{#if type === MarkerType.Arrow}
<polyline
style={polylineStyle}
class="arrow"
style:stroke={color}
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width={strokeWidth}
fill="none"
points="-5,-4 0,0 -5,4"
/>
{:else if type === MarkerType.ArrowClosed}
<polyline
style={polylineStyle}
class="arrowclosed"
style:stroke={color}
style:fill={color}
stroke-linecap="round"
stroke-linejoin="round"
stroke-width={strokeWidth}

View File

@@ -168,10 +168,13 @@
/* Arrowhead marker styles - use CSS custom properties as default */
.xy-flow__arrowhead polyline {
fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));
stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));
}
.xy-flow__arrowhead polyline.arrowclosed {
fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));
}
.xy-flow__connection {
pointer-events: none;