Skip to content

Commit 1708602

Browse files
committed
refactor node help watch source
1 parent f6bc10b commit 1708602

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/components/sidebar/tabs/nodeLibrary/NodeHelpPage.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<script setup lang="ts">
2222
import { whenever } from '@vueuse/core'
2323
import Button from 'primevue/button'
24+
import { computed } from 'vue'
2425
2526
import NodeHelpContent from '@/components/node/NodeHelpContent.vue'
2627
import { useSelectionState } from '@/composables/graph/useSelectionState'
@@ -36,14 +37,15 @@ defineEmits<{
3637
const nodeHelpStore = useNodeHelpStore()
3738
const { nodeDef } = useSelectionState()
3839
39-
// Keep the open help page synced with the current selection while help is open.
40-
whenever(
41-
() => (nodeHelpStore.isHelpOpen ? nodeDef.value : null),
42-
(def) => {
43-
if (!def) return
44-
const currentHelpNode = nodeHelpStore.currentHelpNode
45-
if (currentHelpNode?.nodePath === def.nodePath) return
46-
nodeHelpStore.openHelp(def)
47-
}
40+
const activeHelpDef = computed(() =>
41+
nodeHelpStore.isHelpOpen ? nodeDef.value : null
4842
)
43+
44+
// Keep the open help page synced with the current selection while help is open.
45+
whenever(activeHelpDef, (def) => {
46+
if (!def) return
47+
const currentHelpNode = nodeHelpStore.currentHelpNode
48+
if (currentHelpNode?.nodePath === def.nodePath) return
49+
nodeHelpStore.openHelp(def)
50+
})
4951
</script>

0 commit comments

Comments
 (0)