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) {