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
+6
View File
@@ -0,0 +1,6 @@
---
'@xyflow/react': patch
'@xyflow/svelte': patch
---
Fix open arrow marker using fill color from edge instead of none
+1 -1
View File
@@ -267,7 +267,7 @@ const edgeTypes: EdgeTypes = {
const defaultEdgeOptions = { const defaultEdgeOptions = {
markerEnd: { markerEnd: {
type: MarkerType.ArrowClosed, type: MarkerType.Arrow,
color: 'red', color: 'red',
width: 20, width: 20,
height: 20, height: 20,
@@ -216,7 +216,7 @@
const defaultEdgeOptions = { const defaultEdgeOptions = {
markerEnd: { markerEnd: {
type: MarkerType.ArrowClosed, type: MarkerType.Arrow,
color: 'red', color: 'red',
width: 20, width: 20,
height: 20 height: 20
@@ -11,7 +11,16 @@ const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => {
...(color && { stroke: color }), ...(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) => { const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => {
@@ -20,7 +29,15 @@ const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) =>
...(color && { stroke: color, fill: color }), ...(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 = { export const MarkerSymbols = {
@@ -11,9 +11,6 @@
color = 'none', color = 'none',
strokeWidth strokeWidth
}: MarkerProps = $props(); }: MarkerProps = $props();
// Create inline styles when explicit color is provided
const polylineStyle = color ? `stroke: ${color}; fill: ${color};` : '';
</script> </script>
<marker <marker
@@ -29,16 +26,19 @@
> >
{#if type === MarkerType.Arrow} {#if type === MarkerType.Arrow}
<polyline <polyline
style={polylineStyle} class="arrow"
style:stroke={color}
fill="none"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
stroke-width={strokeWidth} stroke-width={strokeWidth}
fill="none"
points="-5,-4 0,0 -5,4" points="-5,-4 0,0 -5,4"
/> />
{:else if type === MarkerType.ArrowClosed} {:else if type === MarkerType.ArrowClosed}
<polyline <polyline
style={polylineStyle} class="arrowclosed"
style:stroke={color}
style:fill={color}
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
stroke-width={strokeWidth} stroke-width={strokeWidth}
+4 -1
View File
@@ -168,10 +168,13 @@
/* Arrowhead marker styles - use CSS custom properties as default */ /* Arrowhead marker styles - use CSS custom properties as default */
.xy-flow__arrowhead polyline { .xy-flow__arrowhead polyline {
fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));
stroke: 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 { .xy-flow__connection {
pointer-events: none; pointer-events: none;