fix(core): watch applyDefault state in useVueFlow scope

This commit is contained in:
braks
2023-07-24 23:46:59 +02:00
committed by Braks
parent 4ed3acc021
commit 620852b860
2 changed files with 43 additions and 34 deletions
+14 -31
View File
@@ -213,25 +213,6 @@ export function useWatchProps(
}
},
)
watch(
store.applyDefault,
(_, __, onCleanup) => {
if (store.applyDefault.value) {
store.onNodesChange(store.applyNodeChanges)
store.onEdgesChange(store.applyEdgeChanges)
} else {
store.hooks.value.nodesChange.off(store.applyNodeChanges)
store.hooks.value.edgesChange.off(store.applyEdgeChanges)
}
onCleanup(() => {
store.hooks.value.nodesChange.off(store.applyNodeChanges)
store.hooks.value.edgesChange.off(store.applyEdgeChanges)
})
},
{ immediate: true },
)
})
}
@@ -310,18 +291,20 @@ export function useWatchProps(
})
}
;[
watchModelValue,
watchNodesValue,
watchEdgesValue,
watchMinZoom,
watchMaxZoom,
watchTranslateExtent,
watchNodeExtent,
watchApplyDefault,
watchAutoConnect,
watchRest,
].forEach((watch) => watch())
const runAll = () => {
watchModelValue()
watchNodesValue()
watchEdgesValue()
watchMinZoom()
watchMaxZoom()
watchTranslateExtent()
watchNodeExtent()
watchApplyDefault()
watchAutoConnect()
watchRest()
}
runAll()
})
return () => scope.stop()