From db725c1de5cc4e27eacb69674e00ae147701af44 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 9 Aug 2024 16:40:28 +0200 Subject: [PATCH] #5237 Fix for subroutine positioning --- .../rendering-elements/shapes/subroutine.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts index 432c209a4e..c4393c25fa 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts @@ -43,8 +43,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => { const h = bbox.height + node.padding; const x = -bbox.width / 2 - halfPadding; const y = -bbox.height / 2 - halfPadding; - let rect; - const { cssStyles } = node; + const points = [ { x: 0, y: 0 }, { x: w, y: 0 }, @@ -69,9 +68,10 @@ export const subroutine = async (parent: SVGAElement, node: Node) => { shapeSvg.insert(() => l1, ':first-child'); shapeSvg.insert(() => l2, ':first-child'); - rect = shapeSvg.insert(() => roughNode, ':first-child'); - + const rect = shapeSvg.insert(() => roughNode, ':first-child'); + const { cssStyles } = node; rect.attr('class', 'basic label-container').attr('style', cssStyles); + updateNodeBounds(node, rect); } else { const el = insertPolygonShape(shapeSvg, w, h, points); if (nodeStyles) {