fix(core): await node init to add handle bounds in Handle

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-14 12:44:36 +01:00
committed by Braks
parent 8734a16ae6
commit b411c1e411
@@ -39,13 +39,17 @@ const isConnectable = computed(() => {
}) })
onMounted(() => { onMounted(() => {
// set up handle bounds if they don't exist yet (i.e. the handle was added after the node has already been mounted) // set up handle bounds if they don't exist yet and the node has been initialized (i.e. the handle was added after the node has already been mounted)
until(() => node.initialized)
.toBe(true)
.then(() => {
const existingBounds = node.handleBounds[type.value]?.find((b) => b.id === handleId) const existingBounds = node.handleBounds[type.value]?.find((b) => b.id === handleId)
if (!vueFlowRef || existingBounds) return if (!vueFlowRef || existingBounds) return
const viewportNode = vueFlowRef.querySelector('.vue-flow__transformationpane') const viewportNode = vueFlowRef.querySelector('.vue-flow__transformationpane')
if (!nodeEl || !handle.value || !viewportNode) return if (!nodeEl || !handle.value || !viewportNode || !handleId) return
const nodeBounds = nodeEl.value.getBoundingClientRect() const nodeBounds = nodeEl.value.getBoundingClientRect()
@@ -63,6 +67,7 @@ onMounted(() => {
} }
node.handleBounds[type.value] = [...(node.handleBounds[type.value] ?? []), nextBounds] node.handleBounds[type.value] = [...(node.handleBounds[type.value] ?? []), nextBounds]
})
}) })
</script> </script>