fix(expandParent): check for dimensions closes #2280

This commit is contained in:
moklick
2022-07-18 12:05:03 +02:00
parent f2d94ba586
commit 60bbbb4d58
2 changed files with 4 additions and 6 deletions

View File

@@ -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' },

View File

@@ -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;
}