From 95935fbe22c379c545e0abd9ac1f7f2491e7ece8 Mon Sep 17 00:00:00 2001 From: Hellgren Heikki Date: Fri, 26 Sep 2025 21:32:44 +0300 Subject: [PATCH] fix(core-components): fix deps graph scrolling fixes dependency graph scrolling down forever. also fixes the full screen mode to take all the space in the screen. closes #31296 Signed-off-by: Hellgren Heikki --- .changeset/public-wombats-say.md | 5 ++ .../DependencyGraph/DependencyGraph.tsx | 72 +++++++++---------- 2 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 .changeset/public-wombats-say.md diff --git a/.changeset/public-wombats-say.md b/.changeset/public-wombats-say.md new file mode 100644 index 0000000000..b8a72e8436 --- /dev/null +++ b/.changeset/public-wombats-say.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +Fixed dependency graph automatically scrolling forever diff --git a/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx b/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx index df26bb86fd..88cb6ab5e8 100644 --- a/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx +++ b/packages/core-components/src/components/DependencyGraph/DependencyGraph.tsx @@ -54,7 +54,7 @@ const useStyles = makeStyles((theme: Theme) => ({ minWidth: '100%', }, fixedHeight: { - height: '100%', + maxHeight: '100%', }, fullscreen: { backgroundColor: theme.palette.background.paper, @@ -282,7 +282,8 @@ export function DependencyGraph( const [_measureRef] = useMeasure(); const measureRef = once(_measureRef); - const scalableHeight = fit === 'grow' ? maxHeight : containerHeight; + const scalableHeight = + fit === 'grow' && !fullScreenHandle.active ? maxHeight : '100%'; const containerRef = useMemo( () => @@ -335,10 +336,16 @@ export function DependencyGraph( const { width: newContainerWidth, height: newContainerHeight } = root.getBoundingClientRect(); - if (containerWidth !== newContainerWidth) { + if ( + containerWidth !== newContainerWidth && + newContainerWidth <= maxWidth + ) { setContainerWidth(newContainerWidth); } - if (containerHeight !== newContainerHeight) { + if ( + containerHeight !== newContainerHeight && + newContainerHeight <= maxHeight + ) { setContainerHeight(newContainerHeight); } }, 100), @@ -464,39 +471,32 @@ export function DependencyGraph( ); return ( -
- - {allowFullscreen && ( - - - {fullScreenHandle.active ? ( - - ) : ( - - )} - - - )} + {allowFullscreen && ( + + + {fullScreenHandle.active ? ( + + ) : ( + + )} + + + )} +
( height={graphHeight} y={maxHeight / 2 - graphHeight / 2} x={maxWidth / 2 - graphWidth / 2} - viewBox={`0 0 ${graphWidth} ${graphHeight}`} + viewBox={`-25 -25 ${graphWidth + 50} ${graphHeight + 50}`} > {graphEdges.map(e => { const edge = graph.current.edge(e) as GraphEdge; @@ -560,7 +560,7 @@ export function DependencyGraph( - -
+
+ ); }