antonioru / antonioru/beautiful-react-diagrams

Getting Bug when removing node

Đang mở
#157 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2.7k
Fork
171
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Describe the bug**
when i delete node getting undefined issue and its blocked the application

**To Reproduce**
Steps to reproduce the behavior:
1. Go to application
2. Click on remove node action
3. Inside console throwing error message
4. See error attachment.

**Expected behavior**
Should not block the page

**Screenshots**
added screenshots

**Desktop (please complete the following information):**
- OS: [iOS]
- Browser [e.g. chrome]
- Version [latest]

**Additional context**
The problem is to check index should be more than or equal to 0 not -1
Screenshot 2021-07-18 at 6 53 22 PM

1- node_modules/beautiful-react-diagrams/esm/hooks/useSchema/schemaReducer.js

case ON_NODE_REMOVE: { // remove all node's links
let nextLinks = state.links || [];
if (state.nodes) {
const index = findIndex(state.nodes, ['id', action.payload.nodeId]);
// rendering blocked when getting index === -1
**if (index >= 0) {**
const inputPorts = getNodePortsId(state.nodes[index], 'inputs');
const outputPorts = getNodePortsId(state.nodes[index], 'outputs');
nextLinks = nextLinks.filter(
(link) => !inputPorts.includes(link.input) && !outputPorts.includes(link.output),
);
state.nodes.splice(index, 1);
**}**
}

2- node_modules/beautiful-react-diagrams/esm/Diagram/Link/getEntityCoordinates.js

**if (portRefs && entity?.entity?.id && portRefs[entity.entity.id]) {**
var portEl = portRefs[entity.entity.id];

var _bbox = portEl.getBoundingClientRect();

return getRelativePoint([_bbox.x + _bbox.width / 2, _bbox.y + _bbox.height / 2], [canvas.x, canvas.y]);
}

3- node_modules/beautiful-react-diagrams/esm/Diagram/Link/Link.js

var pathOptions = {
**type: input?.type === 'port' || output?.type === 'port' ? 'bezier' : 'curve',**
**inputAlignment: input?.entity?.alignment || null,**
**outputAlignment: output?.entity?.alignment || null**
};

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

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

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.