refactor(core): replace until watcher with onMounted in handle cmp (#1488)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { until } from '@vueuse/core'
|
||||
import { computed, onUnmounted, ref, toRef } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref, toRef } from 'vue'
|
||||
import type { HandleProps } from '../../types'
|
||||
import { Position } from '../../types'
|
||||
import { useHandle, useNode, useVueFlow } from '../../composables'
|
||||
@@ -97,9 +96,13 @@ const isConnectable = computed(() => {
|
||||
|
||||
// todo: remove this and have users handle this themselves using `updateNodeInternals`
|
||||
// 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.dimensions.width && !!node.dimensions.height)
|
||||
.toBe(true, { flush: 'post' })
|
||||
.then(() => {
|
||||
onMounted(() => {
|
||||
// if the node isn't initialized yet, we can't set up the handle bounds
|
||||
// the handle bounds will be automatically set up when the node is initialized (`updateNodeDimensions`)
|
||||
if (!node.dimensions.width || !node.dimensions.height) {
|
||||
return
|
||||
}
|
||||
|
||||
const existingBounds = node.handleBounds[type.value]?.find((b) => b.id === handleId)
|
||||
|
||||
if (!vueFlowRef.value || existingBounds) {
|
||||
@@ -128,7 +131,7 @@ until(() => !!node.dimensions.width && !!node.dimensions.height)
|
||||
}
|
||||
|
||||
node.handleBounds[type.value] = [...(node.handleBounds[type.value] ?? []), nextBounds]
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
// clean up node internals
|
||||
|
||||
Reference in New Issue
Block a user