diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 175ed3a72..ebbe21a50 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -131,7 +131,7 @@ import type { NodeState, VueNodeData } from '@/composables/graph/useGraphNodeManager' -import { useLayoutSync } from '@/composables/graph/useLayout' +import { useLayout, useLayoutSync } from '@/composables/graph/useLayout' import { useNodeBadge } from '@/composables/node/useNodeBadge' import { useCanvasDrop } from '@/composables/useCanvasDrop' import { useContextMenuTranslation } from '@/composables/useContextMenuTranslation' @@ -174,6 +174,7 @@ const workspaceStore = useWorkspaceStore() const canvasStore = useCanvasStore() const executionStore = useExecutionStore() const toastStore = useToastStore() +const { mutations: layoutMutations } = useLayout() const betaMenuEnabled = computed( () => settingStore.get('Comfy.UseNewMenu') !== 'Disabled' ) @@ -479,13 +480,12 @@ const handleNodeSelect = (event: PointerEvent, nodeData: VueNodeData) => { } canvasStore.canvas.selectNode(node) - + // Bring node to front when clicked (similar to LiteGraph behavior) // Skip if node is pinned if (!node.flags?.pinned) { - const { mutations } = useLayout() - mutations.setSource('vue') - mutations.bringNodeToFront(nodeData.id) + layoutMutations.setSource('vue') + layoutMutations.bringNodeToFront(nodeData.id) } node.selected = true diff --git a/src/services/layoutMutations.ts b/src/services/layoutMutations.ts index c3730c604..6a8d14385 100644 --- a/src/services/layoutMutations.ts +++ b/src/services/layoutMutations.ts @@ -134,13 +134,13 @@ class LayoutMutationsImpl implements LayoutMutations { // Get all nodes to find the highest z-index const allNodes = layoutStore.getAllNodes().value let maxZIndex = 0 - - for (const [_, layout] of allNodes) { + + for (const [, layout] of allNodes) { if (layout.zIndex > maxZIndex) { maxZIndex = layout.zIndex } } - + // Set this node's z-index to be one higher than the current max this.setNodeZIndex(nodeId, maxZIndex + 1) }