diff --git a/packages/core/src/components/Nodes/NodeWrapper.vue b/packages/core/src/components/Nodes/NodeWrapper.vue index 814e7428..a9735218 100644 --- a/packages/core/src/components/Nodes/NodeWrapper.vue +++ b/packages/core/src/components/Nodes/NodeWrapper.vue @@ -141,18 +141,13 @@ watch( watch([() => node.extent, () => nodeExtent], ([nodeExtent, globalExtent], [oldNodeExtent, oldGlobalExtent]) => { // update position if extent has actually changed if (nodeExtent !== oldNodeExtent || globalExtent !== oldGlobalExtent) { - if (isParentExtent()) { - // todo: can we solve this without a timeout? Without the timeout the initial extent is not properly calculated - setTimeout(clampPosition, 1) - } else { - clampPosition() - } + clampPosition() } }) // clamp initial position to nodes' extent // if extent is parent, we need dimensions to properly clamp the position -if (isParentExtent()) { +if (node.extent === 'parent' || (typeof node.extent === 'object' && 'range' in node.extent && node.extent.range === 'parent')) { until(() => node.initialized) .toBe(true) .then(clampPosition) @@ -162,10 +157,6 @@ else { clampPosition() } -function isParentExtent() { - return node.extent === 'parent' || (typeof node.extent === 'object' && 'range' in node.extent && node.extent.range === 'parent') -} - /** this re-calculates the current position, necessary for clamping by a node's extent */ function clampPosition() { const { computedPosition, position } = calcNextPosition(node, node.computedPosition, nodeExtent, parentNode) diff --git a/packages/core/src/utils/changes.ts b/packages/core/src/utils/changes.ts index b474885e..71d38af7 100644 --- a/packages/core/src/utils/changes.ts +++ b/packages/core/src/utils/changes.ts @@ -160,13 +160,19 @@ export const applyChanges = < } } - if (typeof currentChange.resizing === 'boolean') element.resizing = currentChange.resizing + if (typeof currentChange.resizing !== 'undefined') element.resizing = currentChange.resizing if (element.expandParent && element.parentNode) { const parent = elements[elementIds.indexOf(element.parentNode)] if (parent && isGraphNode(parent)) { - handleParentExpand(element, parent) + if (!parent.initialized) { + nextTick(() => { + handleParentExpand(element, parent) + }) + } else { + handleParentExpand(element, parent) + } } }