From 60bbbb4d5872c124350dd7ca4e6c04cc97130201 Mon Sep 17 00:00:00 2001 From: moklick Date: Mon, 18 Jul 2022 12:05:03 +0200 Subject: [PATCH] fix(expandParent): check for dimensions closes #2280 --- example/src/Subflow/index.tsx | 1 + src/utils/changes.ts | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/example/src/Subflow/index.tsx b/example/src/Subflow/index.tsx index 6b6c4799..a3ae8ab5 100644 --- a/example/src/Subflow/index.tsx +++ b/example/src/Subflow/index.tsx @@ -91,6 +91,7 @@ const initialNodes: Node[] = [ position: { x: 225, y: 50 }, className: 'light', parentNode: '5', + expandParent: true, }, { id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 }, className: 'light' }, { id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 }, className: 'light' }, diff --git a/src/utils/changes.ts b/src/utils/changes.ts index 76bc716e..2b6113eb 100644 --- a/src/utils/changes.ts +++ b/src/utils/changes.ts @@ -10,17 +10,14 @@ function handleParentExpand(res: any[], updateItem: any) { if (extendWidth > 0 || extendHeight > 0 || updateItem.position.x < 0 || updateItem.position.y < 0) { parent.style = { ...parent.style } || {}; + parent.style.width = parent.style.width ?? parent.width; + parent.style.height = parent.style.height ?? parent.height; + if (extendWidth > 0) { - if (!parent.style.width) { - parent.style.width = parent.width; - } parent.style.width += extendWidth; } if (extendHeight > 0) { - if (!parent.style.height) { - parent.style.height = parent.height; - } parent.style.height += extendHeight; }