Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/components/network-modification-tree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,23 @@ const NetworkModificationTree = ({ onNodeContextMenu, studyUuid }) => {
// trigger focus when requested from outside (ex: from root network modification results)
useTreeNodeFocus(handleFocusNode);

// FIX : when fitting the view, the nodes are not yet rendered, so the view is not correctly
// centered and zoomed on the nodes. We need to wait for the nodes to be rendered and then fit the view.
// cf https://github.com/xyflow/xyflow/issues/533
const onReactFlowInit = (rf) => {
rf.fitView();
};
// END OF FIX

return (
<Box sx={styles.modificationTree}>
<ReactFlow
nodes={nodes}
edges={edges}
onNodesChange={handleNodesChange}
onEdgesChange={onEdgesChange}
fitView
// fitView : see fix in onReactFlowInit function above
onInit={onReactFlowInit}
snapToGrid
snapGrid={snapGrid}
onNodeContextMenu={onNodeContextMenu}
Expand Down
Loading