-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing undefined entity on node remove #34
Fixing undefined entity on node remove #34
Conversation
1c13650
to
ec047df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, please check my final review
docs/dynamic-nodes.md
Outdated
const [nodeId, setNodeId] = useState(schema.nodes.length+1); | ||
const deleteNodeFromSchema = (id) => { | ||
const nodeToRemove = schema.nodes.find(node => node.id === id); | ||
removeNode(nodeToRemove); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix this indentation
src/Diagram/Diagram.js
Outdated
@@ -34,6 +34,13 @@ const Diagram = (props) => { | |||
nodeRefs[nodeId] = nodeEl; | |||
}; | |||
|
|||
// when a node is deleted, remove its references | |||
const onNodeRemove = (nodeId, inputsPorts, outputsPorts) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we can use useCalback?
src/hooks/useSchema/schemaReducer.js
Outdated
@@ -19,16 +20,23 @@ const schemaReducer = (state, action) => { | |||
nodes: state.nodes || [], | |||
links: state.links || [], | |||
}); | |||
case ON_NODE_REMOVE: | |||
case ON_NODE_REMOVE: { // remove all node's links | |||
let linksToKeep = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let nextLinks = state.links || [];
tests/DiagramNode.spec.js
Outdated
@@ -5,6 +5,7 @@ import DiagramNode from '../dist/Diagram/DiagramNode/DiagramNode'; | |||
|
|||
describe('DiagramNode component', () => { | |||
afterEach(cleanup); | |||
sinon.restore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afterEach(() => {
clearnup();
sinon.restore();
});
b3aa847
to
772270b
Compare
772270b
to
b5f85c8
Compare
Description
The fix consists in removing the links associated with a node, when this one deleted.
Related Issue
#33