Skip to content

Commit

Permalink
fix: fix issue that arrow cannot update
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed May 30, 2024
1 parent 0982c1e commit 4c9a701
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 1 deletion.
38 changes: 38 additions & 0 deletions packages/g6/__tests__/bugs/element-edge-update-arrow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { createGraph } from '../utils';

describe('bug: element-edge-update-arrow', () => {
it('should update edge arrow', async () => {
const graph = createGraph({
animation: false,
data: {
nodes: [
{ id: 'node-0', style: { x: 100, y: 100 } },
{ id: 'node-1', style: { x: 200, y: 100 } },
],
edges: [
{
source: 'node-0',
target: 'node-1',
style: { startArrow: true, startArrowFill: 'red', endArrow: true, endArrowFill: 'green' },
},
],
},
});

await graph.render();

await expect(graph).toMatchSnapshot(__filename);

graph.updateEdgeData([
{
source: 'node-0',
target: 'node-1',
style: { startArrowFill: 'purple', startArrowStroke: 'blue', endArrowFill: 'pink', endArrowStroke: 'yellow' },
},
]);

await graph.render();

await expect(graph).toMatchSnapshot(__filename, 'update-arrow');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/g6/src/elements/edges/base-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> {
? (['markerStart', 'markerStartOffset', 'startArrowOffset'] as const)
: (['markerEnd', 'markerEndOffset', 'endArrowOffset'] as const);

const arrow = keyShape.style[marker];
const arrow = keyShape.parsedStyle[marker];
// update
if (arrow) arrow.attr(arrowStyle);
// create
Expand Down

0 comments on commit 4c9a701

Please sign in to comment.