Make useTreeExpansion hook accept expandedKeys as param (#826)

This commit is contained in:
Chenlei Hu
2024-09-14 11:27:38 +09:00
committed by GitHub
parent ebdcd92977
commit fef780a72f
3 changed files with 6 additions and 7 deletions

View File

@@ -92,7 +92,8 @@ import { useNodeBookmarkStore } from '@/stores/nodeBookmarkStore'
const nodeDefStore = useNodeDefStore()
const nodeBookmarkStore = useNodeBookmarkStore()
const { expandedKeys, expandNode, toggleNodeOnEvent } = useTreeExpansion()
const expandedKeys = ref<Record<string, boolean>>({})
const { expandNode, toggleNodeOnEvent } = useTreeExpansion(expandedKeys)
const nodeBookmarkTreeExplorerRef = ref<InstanceType<
typeof NodeBookmarkTreeExplorer

View File

@@ -47,7 +47,8 @@ const props = defineProps<{
filteredNodeDefs: ComfyNodeDefImpl[]
}>()
const { expandedKeys, expandNode, toggleNodeOnEvent } = useTreeExpansion()
const expandedKeys = ref<Record<string, boolean>>({})
const { expandNode, toggleNodeOnEvent } = useTreeExpansion(expandedKeys)
const handleNodeClick = (
node: RenderedTreeExplorerNode<ComfyNodeDefImpl>,

View File

@@ -1,9 +1,7 @@
import { ref } from 'vue'
import { Ref } from 'vue'
import type { TreeNode } from 'primevue/treenode'
export function useTreeExpansion() {
const expandedKeys = ref<Record<string, boolean>>({})
export function useTreeExpansion(expandedKeys: Ref<Record<string, boolean>>) {
const toggleNode = (node: TreeNode) => {
if (node.key && typeof node.key === 'string') {
if (node.key in expandedKeys.value) {
@@ -63,7 +61,6 @@ export function useTreeExpansion() {
}
return {
expandedKeys,
toggleNode,
toggleNodeRecursive,
expandNode,