Remove refresh button when all nodes are selected (#3690)

This commit is contained in:
Chenlei Hu
2025-04-29 19:59:49 -04:00
committed by GitHub
parent 4828af9a13
commit 98d7256da4
2 changed files with 3 additions and 27 deletions

View File

@@ -99,18 +99,6 @@ test.describe('Selection Toolbox', () => {
).not.toBeVisible()
})
test('displays refresh button in toolbox when all nodes are selected', async ({
comfyPage
}) => {
// Select all nodes
await comfyPage.page.focus('canvas')
await comfyPage.page.keyboard.press('Control+A')
await expect(
comfyPage.page.locator('.selection-toolbox .pi-refresh')
).toBeVisible()
})
test('displays bypass button in toolbox when nodes are selected', async ({
comfyPage
}) => {

View File

@@ -1,8 +1,6 @@
import type { LGraphNode } from '@comfyorg/litegraph'
import type { IWidget } from '@comfyorg/litegraph'
import type { IWidget, LGraphNode } from '@comfyorg/litegraph'
import { computed, ref, watchEffect } from 'vue'
import { useCommandStore } from '@/stores/commandStore'
import { useCanvasStore } from '@/stores/graphStore'
import { isLGraphNode } from '@/utils/litegraphUtil'
@@ -20,14 +18,10 @@ const isRefreshableWidget = (widget: IWidget): widget is RefreshableWidget =>
*/
export const useRefreshableSelection = () => {
const graphStore = useCanvasStore()
const commandStore = useCommandStore()
const selectedNodes = ref<LGraphNode[]>([])
const isAllNodesSelected = ref(false)
watchEffect(() => {
selectedNodes.value = graphStore.selectedItems.filter(isLGraphNode)
isAllNodesSelected.value =
graphStore.canvas?.graph?.nodes?.every((node) => !!node.selected) ?? false
})
const refreshableWidgets = computed(() =>
@@ -36,18 +30,12 @@ export const useRefreshableSelection = () => {
)
)
const isRefreshable = computed(
() => refreshableWidgets.value.length > 0 || isAllNodesSelected.value
)
const isRefreshable = computed(() => refreshableWidgets.value.length > 0)
async function refreshSelected() {
if (!isRefreshable.value) return
if (isAllNodesSelected.value) {
await commandStore.execute('Comfy.RefreshNodeDefinitions')
} else {
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
}
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
}
return {