Skip to content

Commit f0f7e7e

Browse files
committed
fix(edges): add missing edge class to edge wrapper
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent cd77871 commit f0f7e7e

File tree

9 files changed

+48
-43
lines changed

9 files changed

+48
-43
lines changed

.changeset/cyan-tips-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vue-flow/core': patch
3+
---
4+
5+
Add missing edge class to edge wrapper

packages/core/src/components/Edges/BaseEdge.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,28 @@ import type { BaseEdgeProps } from '~/types'
66
* The base edge is a simple wrapper for svg path
77
* You can use the base edge in your custom edges and just pass down the necessary props
88
*/
9-
const BaseEdge: FunctionalComponent<BaseEdgeProps> = function ({
10-
path,
11-
label,
12-
labelX,
13-
labelY,
14-
labelBgBorderRadius,
15-
labelBgPadding,
16-
labelBgStyle,
17-
labelShowBg = true,
18-
labelStyle,
19-
markerStart,
20-
markerEnd,
21-
style,
22-
interactionWidth = 20,
23-
}) {
9+
const BaseEdge: FunctionalComponent<BaseEdgeProps> = function (
10+
{
11+
path,
12+
label,
13+
labelX,
14+
labelY,
15+
labelBgBorderRadius,
16+
labelBgPadding,
17+
labelBgStyle,
18+
labelShowBg = true,
19+
labelStyle,
20+
markerStart,
21+
markerEnd,
22+
interactionWidth = 20,
23+
},
24+
{ attrs },
25+
) {
2426
return [
2527
h('path', {
26-
'style': style,
28+
'style': attrs.style,
29+
'class': ['vue-flow__edge-path', attrs.class].join(' '),
2730
'd': path,
28-
'class': 'vue-flow__edge-path',
2931
'marker-end': markerEnd,
3032
'marker-start': markerStart,
3133
}),
@@ -64,7 +66,6 @@ BaseEdge.props = [
6466
'labelStyle',
6567
'markerStart',
6668
'markerEnd',
67-
'style',
6869
'interactionWidth',
6970
]
7071

packages/core/src/components/Edges/BezierEdge.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
33
import { Position } from '~/types'
44
import type { EdgeProps } from '~/types'
55

6-
const BezierEdge: FunctionalComponent<EdgeProps> = function ({
7-
sourcePosition = Position.Bottom,
8-
targetPosition = Position.Top,
9-
...props
10-
}) {
6+
const BezierEdge: FunctionalComponent<EdgeProps> = function (
7+
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
8+
{ attrs },
9+
) {
1110
const [path, labelX, labelY] = getBezierPath({
1211
sourcePosition,
1312
targetPosition,
@@ -19,6 +18,7 @@ const BezierEdge: FunctionalComponent<EdgeProps> = function ({
1918
labelX,
2019
labelY,
2120
...props,
21+
...attrs,
2222
})
2323
}
2424

@@ -38,7 +38,6 @@ BezierEdge.props = [
3838
'curvature',
3939
'markerEnd',
4040
'markerStart',
41-
'style',
4241
'interactionWidth',
4342
]
4443

packages/core/src/components/Edges/EdgeWrapper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ const EdgeWrapper = defineComponent({
137137
targetPosition,
138138
)
139139

140+
const edgeClass = edge.class instanceof Function ? edge.class(edge) : edge.class
141+
const edgeStyle = edge.style instanceof Function ? edge.style(edge) : edge.style
142+
140143
return h(
141144
'g',
142145
{
@@ -145,6 +148,7 @@ const EdgeWrapper = defineComponent({
145148
'class': [
146149
'vue-flow__edge',
147150
`vue-flow__edge-${props.type === false ? 'default' : props.name}`,
151+
edgeClass,
148152
{
149153
updating: mouseOver,
150154
selected: edge.selected,
@@ -180,7 +184,7 @@ const EdgeWrapper = defineComponent({
180184
labelBgBorderRadius: edge.labelBgBorderRadius,
181185
data: edge.data,
182186
events: { ...edge.events, ...hooks.on },
183-
style: edge.style instanceof Function ? edge.style(edge) : edge.style,
187+
style: edgeStyle,
184188
markerStart: `url(#${getMarkerId(edge.markerStart)})`,
185189
markerEnd: `url(#${getMarkerId(edge.markerEnd)})`,
186190
sourcePosition,

packages/core/src/components/Edges/SimpleBezierEdge.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
33
import { Position } from '~/types'
44
import type { EdgeProps } from '~/types'
55

6-
const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({
7-
sourcePosition = Position.Bottom,
8-
targetPosition = Position.Top,
9-
...props
10-
}) {
6+
const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function (
7+
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
8+
{ attrs },
9+
) {
1110
const [path, labelX, labelY] = getSimpleBezierPath({
1211
sourcePosition,
1312
targetPosition,
@@ -19,6 +18,7 @@ const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({
1918
labelX,
2019
labelY,
2120
...props,
21+
...attrs,
2222
})
2323
}
2424

@@ -37,7 +37,6 @@ SimpleBezierEdge.props = [
3737
'targetY',
3838
'markerEnd',
3939
'markerStart',
40-
'style',
4140
'interactionWidth',
4241
]
4342

packages/core/src/components/Edges/SmoothStepEdge.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
33
import type { SmoothStepEdgeProps } from '~/types'
44
import { Position } from '~/types'
55

6-
const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
7-
sourcePosition = Position.Bottom,
8-
targetPosition = Position.Top,
9-
...props
10-
}) {
6+
const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function (
7+
{ sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
8+
{ attrs },
9+
) {
1110
const [path, labelX, labelY] = getSmoothStepPath({
1211
sourcePosition,
1312
targetPosition,
@@ -19,6 +18,7 @@ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
1918
labelX,
2019
labelY,
2120
...props,
21+
...attrs,
2222
})
2323
}
2424

@@ -38,7 +38,6 @@ SmoothStepEdge.props = [
3838
'borderRadius',
3939
'markerEnd',
4040
'markerStart',
41-
'style',
4241
'interactionWidth',
4342
]
4443

packages/core/src/components/Edges/StepEdge.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { FunctionalComponent } from 'vue'
22
import SmoothStepEdge from './SmoothStepEdge'
33
import type { EdgeProps } from '~/types'
44

5-
const StepEdge: FunctionalComponent<EdgeProps> = function (props) {
6-
return h(SmoothStepEdge, { ...props, borderRadius: 0 })
5+
const StepEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) {
6+
return h(SmoothStepEdge, { ...props, ...attrs, borderRadius: 0 })
77
}
88

99
StepEdge.props = [
@@ -21,7 +21,6 @@ StepEdge.props = [
2121
'targetY',
2222
'markerEnd',
2323
'markerStart',
24-
'style',
2524
'interactionWidth',
2625
]
2726

packages/core/src/components/Edges/StraightEdge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import type { FunctionalComponent } from 'vue'
22
import BaseEdge from './BaseEdge'
33
import type { EdgeProps } from '~/types'
44

5-
const StraightEdge: FunctionalComponent<EdgeProps> = function (props) {
5+
const StraightEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) {
66
const [path, labelX, labelY] = getStraightPath(props)
77

88
return h(BaseEdge, {
99
path,
1010
labelX,
1111
labelY,
1212
...props,
13+
...attrs,
1314
})
1415
}
1516

@@ -26,7 +27,6 @@ StraightEdge.props = [
2627
'targetY',
2728
'markerEnd',
2829
'markerStart',
29-
'style',
3030
'interactionWidth',
3131
]
3232

packages/core/src/types/edge.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export interface BaseEdgeProps {
160160
labelY: number
161161
path: string
162162
label?: any
163-
style?: CSSProperties
164163
labelStyle?: any
165164
labelShowBg?: boolean
166165
labelBgStyle?: any

0 commit comments

Comments
 (0)