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