From a7a9185222d425e3e7ac4b8cbe6071e0a36f149b Mon Sep 17 00:00:00 2001 From: Per Brolin Date: Mon, 30 Sep 2024 10:44:01 +0200 Subject: [PATCH] Fix default size if not provided --- .../rendering-elements/shapes/stateStart.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts index ae44a3c4d..ed5fc79b6 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts @@ -12,6 +12,28 @@ export const stateStart = ( ) => { const { lineColor } = themeVariables; + // If incoming height & width are present, subtract the padding from them + // as labelHelper does not take padding into account + // also check if the width or height is less than minimum default values (50), + // if so set it to min value + if (node.width || node.height) { + if ((node.width ?? 0) < 50) { + node.width = 50; + } + + if ((node.height ?? 0) < 50) { + node.height = 50; + } + } + + if (!node.width) { + node.width = 50; + } + + if (!node.height) { + node.width = 50; + } + const shapeSvg = parent .insert('g') .attr('class', 'node default')