From 6fcf5c8348ceb32467606cd30514f355b3814b18 Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 12 Aug 2025 15:15:21 -0700 Subject: [PATCH] feat(selection): Conditionally hide "Convert to Subgraph" button Implements the feature from issue #4866. The "Convert to Subgraph" button in the selection toolbox is now hidden under the following conditions: - The selection consists only of group nodes. - A single SubgraphNode is selected. This prevents users from attempting to convert invalid selections into subgraphs. --- .../ConvertToSubgraphButton.vue | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/graph/selectionToolbox/ConvertToSubgraphButton.vue b/src/components/graph/selectionToolbox/ConvertToSubgraphButton.vue index ef6e27260..44776b1de 100644 --- a/src/components/graph/selectionToolbox/ConvertToSubgraphButton.vue +++ b/src/components/graph/selectionToolbox/ConvertToSubgraphButton.vue @@ -34,7 +34,7 @@ import Button from 'primevue/button' import { computed } from 'vue' import { useI18n } from 'vue-i18n' -import { SubgraphNode } from '@/lib/litegraph/src/litegraph' +import { LGraphGroup, SubgraphNode } from '@/lib/litegraph/src/litegraph' import { useCommandStore } from '@/stores/commandStore' import { useCanvasStore } from '@/stores/graphStore' @@ -48,7 +48,25 @@ const isUnpackVisible = computed(() => { canvasStore.selectedItems[0] instanceof SubgraphNode ) }) + const isConvertVisible = computed(() => { + const items = canvasStore.selectedItems + if (!items || items.length === 0) { + return false + } + + // Unpack button takes precedence for single subgraph node + if (items.length === 1 && items[0] instanceof SubgraphNode) { + return false + } + + // Hide if ALL selected items are groups + const allAreGroups = items.every((item) => item instanceof LGraphGroup) + if (allAreGroups) { + return false + } + + // Otherwise, show it, assuming there's some selection return ( canvasStore.groupSelected || canvasStore.rerouteSelected ||