From fd6b875f871821d922002d888889cdce2bafb4fb Mon Sep 17 00:00:00 2001 From: yari-dewalt Date: Mon, 21 Oct 2024 16:09:55 -0700 Subject: [PATCH] Fix subgraph / cluster node width based off of label --- packages/mermaid-layout-elk/src/render.ts | 1 + packages/mermaid/src/diagrams/class/classDb.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/mermaid-layout-elk/src/render.ts b/packages/mermaid-layout-elk/src/render.ts index 1f207cbca8..fb18a8daa5 100644 --- a/packages/mermaid-layout-elk/src/render.ts +++ b/packages/mermaid-layout-elk/src/render.ts @@ -136,6 +136,7 @@ export const render = async ( const clusterNode = JSON.parse(JSON.stringify(node)); clusterNode.x = node.offset.posX + node.width / 2; clusterNode.y = node.offset.posY + node.height / 2; + clusterNode.width = Math.max(clusterNode.width, node.labelData.width); await insertCluster(subgraphEl, clusterNode); log.debug('Id (UIO)= ', node.id, node.width, node.shape, node.labels); diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts index 9c8a642c6f..5699437367 100644 --- a/packages/mermaid/src/diagrams/class/classDb.ts +++ b/packages/mermaid/src/diagrams/class/classDb.ts @@ -590,6 +590,7 @@ export const getData = () => { id: namespace.id, label: namespace.id, isGroup: true, + padding: config.class!.padding ?? 16, // parent node must be one of [rect, roundedWithTitle, noteGroup, divider] shape: 'rect', cssStyles: ['fill: none', 'stroke: black'],