Skip to content

Commit

Permalink
[2464] Fix fit-to-screen after the first layout
Browse files Browse the repository at this point in the history
Bug: #2464
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
  • Loading branch information
gcoutable authored and sbegaudeau committed Nov 30, 2023
1 parent e2bccdc commit 60e8c73
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ It uses our algorithm instead of elk.js to perform the arrange-all.
Make some border node transparent when the node is in a list node in the convert engine.
- https://github.com/eclipse-sirius/sirius-web/issues/2646[#2646] [diagram] Fix an issue where the palette was re rendering too much.
- https://github.com/eclipse-sirius/sirius-web/issues/2685[#2685] [diagram] Fix direct edit of edge labels with F2.
- https://github.com/eclipse-sirius/sirius-web/issues/2464[#2464] [diagram] Apply the fit-to-screen after the first layout

=== New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const DiagramRenderer = ({ diagramRefreshedEventPayload, selection, setSe

setNodes(convertedDiagram.nodes);
setEdges(convertedDiagram.edges);
fitToScreen();
} else if (cause === 'refresh') {
const previousDiagram: RawDiagram = {
nodes: nodes as Node<NodeData, DiagramNodeType>[],
Expand All @@ -113,7 +114,6 @@ export const DiagramRenderer = ({ diagramRefreshedEventPayload, selection, setSe
setEdges(laidOutDiagram.edges);
hideDiagramPalette();
resetReferencePosition();
fitToScreen();

synchronizeLayoutData(diagramRefreshedEventPayload.id, laidOutDiagram);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useInitialFitToScreen = (): UseInitialFitToScreenValue => {
// We cannot perform the fit to screen directly but instead need to wait for the next render in order to retrieve the updated nodes and edges in the react flow instance
useEffect(() => {
if (state.shouldPerformFitToScreen) {
reactFlowInstance.fitView({ minZoom: 0.5 });
reactFlowInstance.fitView({ duration: 200 });
setState((prevState) => ({ ...prevState, initialFitToScreenPerformed: true, shouldPerformFitToScreen: false }));
}
}, [state.shouldPerformFitToScreen]);
Expand Down

0 comments on commit 60e8c73

Please sign in to comment.