refactor(nodes): recreate scope on mount

This commit is contained in:
braks
2022-08-01 21:10:14 +02:00
committed by Braks
parent 3f336a12af
commit d468fb7f1d
@@ -38,7 +38,7 @@ const nodeElement = ref()
const { emit, on } = useNodeHooks(node, emits)
const scope = effectScope()
let scope: ReturnType<typeof effectScope> | undefined = effectScope()
const dragging = useDrag({
id,
@@ -91,11 +91,13 @@ onUpdateNodeInternals((updateIds) => {
})
onMounted(() => {
if (!scope) scope = effectScope()
scope.run(() => {
watch(
[() => node.width, () => node.height, () => node.type, () => node.sourcePosition, () => node.targetPosition],
() => {
updateNodeDimensions([{ id, nodeElement: nodeElement.value }])
updateNodeDimensions([{ id, nodeElement: nodeElement.value, forceUpdate: true }])
},
{ flush: 'post', immediate: true },
)
@@ -132,7 +134,8 @@ onMounted(() => {
onBeforeUnmount(() => {
observer.stop()
scope.stop()
scope?.stop()
scope = undefined
})
const onMouseEnter = (event: MouseEvent) => {