#v12 - Repetitive calling onNodeChanges after add
1 messages · Page 1 of 1 (latest)
Code Repo:
https://github.com/PlutoyDev/satisfactory-planning-tool
v11: on main branch
v12: on xyflow-latest
Where can we find the flow?
Not exactly sure why you create your own "change" in here
onDrop: e => {
e.preventDefault();
const { rfInstance, selNode, onNodesChange, onSelectionChange } = get();
const type = e.dataTransfer.getData('application/reactflow') as NodeTypeKeys;
if (!type || !rfInstance) {
return;
}
const position = rfInstance.screenToFlowPosition({ x: e.clientX, y: e.clientY });
const node = { id: nanoid(), type, position, selected: true, data: {} };
const changes: NodeChange[] = [{ type: 'add', item: node }];
if (selNode) {
changes.push({ type: 'select', id: selNode.id, selected: false });
}
onNodesChange(changes);
onSelectionChange({ nodes: [node], edges: [] });
},
instead of using the built-in addNodes or setNodes function 🤔
Is there a specific reason for that?
The flow is in here, https://github.com/PlutoyDev/satisfactory-planning-tool/blob/main/src%2Fpages%2FProductionGraph.tsx
The onNodeChange function also helps with saving the changes (after denounce).
Iirc in v11, when setNodes is called, onNodeChange will be called with reset changes for all the nodes in the array.
I will try to debug it more tomorrow / weekend.
This repetitive behavior isn't present in v11.
Changes made doesn't seem to introduce the bug either, but i might be wrong
.
the issue is that you are not applying the dimensions correctly
this
if (dimensions) {
node.width = dimensions.width;
node.height = dimensions.height;
}
should be
if (dimensions) {
node.computed = node.computed ?? {};
node.computed.width = dimensions.width;
node.computed.height = dimensions.height;
}
I've changed it when updating to v12.
I tried using the provided applyNodeChanges and it's still re-calling the function multiple times.
At the point of migration to v12, no
There was a commit on the main branch (using v11) the recipeNode will change size when the user changes its recipe, requires user input.
Add node change
you say that you get changes of type "add" ?