From 2ef8b7cfd706307b00f48a3304bcf18aeeccfc91 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 24 Apr 2025 07:54:27 +1000 Subject: [PATCH] Fix opening search from context menu (#3591) Co-authored-by: github-actions --- browser_tests/tests/nodeSearchBox.spec.ts | 13 +++++++++++++ src/components/searchbox/NodeSearchBoxPopover.vue | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/browser_tests/tests/nodeSearchBox.spec.ts b/browser_tests/tests/nodeSearchBox.spec.ts index 5f9ae0bae..ddb67d84e 100644 --- a/browser_tests/tests/nodeSearchBox.spec.ts +++ b/browser_tests/tests/nodeSearchBox.spec.ts @@ -251,4 +251,17 @@ test.describe('Release context menu', () => { 'link-release-context-menu.png' ) }) + + test('Can search and add node from context menu', async ({ + comfyPage, + comfyMouse + }) => { + await comfyPage.disconnectEdge() + await comfyMouse.move({ x: 10, y: 10 }) + await comfyPage.clickContextMenuItem('Search') + await comfyPage.searchBox.fillAndSelectFirstNode('CLIP Prompt') + await expect(comfyPage.canvas).toHaveScreenshot( + 'link-context-menu-search.png' + ) + }) }) diff --git a/src/components/searchbox/NodeSearchBoxPopover.vue b/src/components/searchbox/NodeSearchBoxPopover.vue index 46c2c053b..c063ff593 100644 --- a/src/components/searchbox/NodeSearchBoxPopover.vue +++ b/src/components/searchbox/NodeSearchBoxPopover.vue @@ -158,7 +158,10 @@ const showContextMenu = (e: CanvasPointerEvent) => { const commonOptions = { e, allow_searchbox: true, - showSearchBox: () => showSearchBox(e) + showSearchBox: () => { + cancelResetOnContextClose() + showSearchBox(e) + } } const connectionOptions = toType === 'input' @@ -200,7 +203,12 @@ const showContextMenu = (e: CanvasPointerEvent) => { ) // Reset when the context menu is closed - useEventListener(menu.controller.signal, 'abort', reset, options) + const cancelResetOnContextClose = useEventListener( + menu.controller.signal, + 'abort', + reset, + options + ) } // Disable litegraph's default behavior of release link and search box.