feat(core): cleanup handle bounds from node when handle is unmounted

This commit is contained in:
braks
2023-10-05 21:42:45 +02:00
committed by Braks
parent 5e78795764
commit ce1647ad1e

View File

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { toRef, until } from '@vueuse/core'
import { computed, ref } from 'vue'
import { computed, onBeforeUnmount, ref } from 'vue'
import type { HandleProps } from '../../types/handle'
import { Position } from '../../types'
import { useHandle, useNode, useVueFlow } from '../../composables'
@@ -131,6 +131,14 @@ until(() => node.initialized)
node.handleBounds[type.value] = [...(node.handleBounds[type.value] ?? []), nextBounds]
})
onBeforeUnmount(() => {
// clean up node internals
const handleBounds = node.handleBounds[type.value]
if (handleBounds) {
node.handleBounds[type.value] = handleBounds.filter((b) => b.id !== handleId.value)
}
})
function onPointerDown(event: MouseEvent | TouchEvent) {
const isMouseTriggered = isMouseEvent(event)