mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
Make useTreeExpansion hook accept expandedKeys as param (#826)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user