[Bug Report]: 更新节点宽高时边路径不跟随变化

Đang mở
#2,011 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

@DymoneLewis đang làm issue này rồi.

Từ ngày 13/12/2024.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

core: edge core: node type:bug
发生了什么?

排查了一下1.0版本的demo里也复现了这个问题,应该是个陈年bug
https://codesandbox.io/p/devbox/logicflowdemo-g3nc5g
初步定位到问题的原因主要在于节点宽高变化后,对应的锚点坐标没有更新,从而导致边的起终点没变化的现象出现
核心只要解决锚点坐标不更新就行

目前尝试了一下比较可行的临时解决方案是手动删除再新增边:

const { nodes } = lfRef.current?.graphModel
nodes.forEach((node) => {
const {
incoming: { edges: incomingEdges },
outgoing: { edges: outgoingEdges },
} = node;
node.setProperties({
width: 20,
height: 100,
});
incomingEdges.forEach((edge) => {
const edgeInfo = edge.getData();
lfRef.current?.deleteEdge(edgeInfo.id);
lfRef.current?.addEdge({
sourceNodeId: edgeInfo.sourceNodeId,
targetNodeId: edgeInfo.targetNodeId,
sourceAnchorId: edgeInfo.sourceAnchorId,
targetAnchorId: edgeInfo.targetAnchorId,
type: edgeInfo.type,
properties: edgeInfo.properties,
})
});
outgoingEdges.forEach((edge) => {
const edgeInfo = edge.getData();
lfRef.current?.deleteEdge(edgeInfo.id);
lfRef.current?.addEdge({
sourceNodeId: edgeInfo.sourceNodeId,
targetNodeId: edgeInfo.targetNodeId,
sourceAnchorId: edgeInfo.sourceAnchorId,
targetAnchorId: edgeInfo.targetAnchorId,
type: edgeInfo.type,
properties: edgeInfo.properties,
})
});

修复方案。。。暂时还没有想的特别清楚,也欢迎看到的朋友一起讨论

logicflow/core版本

1.x + 2.x

logicflow/extension版本
logicflow/engine版本

No response

浏览器&环境

Chrome

Ngôn ngữ chính
TypeScript
Star
11.8k
Fork
1.4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của didi/LogicFlow

Tất cả issue của didi/LogicFlow

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.