Skip to content

Commit

Permalink
link release pops up searchbox by default (#348) (#350)
Browse files Browse the repository at this point in the history
* link release pops up searchbox by default (#348)

* link release pops up searchbox by default

* Update browser test

* Fix tests

* Update test expectations [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
huchenlei and github-actions authored Aug 9, 2024
1 parent 078df41 commit 4b83ee3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 21 deletions.
3 changes: 3 additions & 0 deletions browser_tests/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ test.describe('Node Interaction', () => {

test('Can disconnect/connect edge', async ({ comfyPage }) => {
await comfyPage.disconnectEdge()
// Close search menu poped up.
await comfyPage.page.keyboard.press('Escape')
await comfyPage.nextFrame()
await expect(comfyPage.canvas).toHaveScreenshot(
'disconnected-edge-with-menu.png'
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions browser_tests/nodeSearchBox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ test.describe('Node search box', () => {
})

test('Can trigger on link release', async ({ comfyPage }) => {
await comfyPage.page.keyboard.down('Shift')
await comfyPage.disconnectEdge()
await expect(comfyPage.searchBox.input).toHaveCount(1)
})

test('Does not trigger on link release (no shift)', async ({ comfyPage }) => {
await comfyPage.disconnectEdge()
await expect(comfyPage.searchBox.input).toHaveCount(0)
})

test('Can add node', async ({ comfyPage }) => {
await comfyPage.doubleClickCanvas()
await expect(comfyPage.searchBox.input).toHaveCount(1)
Expand All @@ -26,9 +20,7 @@ test.describe('Node search box', () => {
})

test('Can auto link node', async ({ comfyPage }) => {
await comfyPage.page.keyboard.down('Shift')
await comfyPage.disconnectEdge()
await comfyPage.page.keyboard.up('Shift')
await comfyPage.searchBox.fillAndSelectFirstNode('CLIPTextEncode')
await expect(comfyPage.canvas).toHaveScreenshot('auto-linked-node.png')
})
Expand All @@ -44,7 +36,6 @@ test.describe('Node search box', () => {
x: 5,
y: 5
}

await comfyPage.page.keyboard.down('Shift')
await comfyPage.dragAndDrop(outputSlot1Pos, emptySpacePos)
await comfyPage.page.keyboard.up('Shift')
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineConfig({
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
timeout: 5000
timeout: 15000
}

// {
Expand Down
11 changes: 8 additions & 3 deletions src/components/graph/GraphCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ const betaMenuEnabled = computed(
const nodeSearchEnabled = computed<boolean>(
() => settingStore.get('Comfy.NodeSearchBoxImpl') === 'default'
)
watch(nodeSearchEnabled, (newVal) => {
if (comfyApp.canvas) comfyApp.canvas.allow_searchbox = !newVal
})
watch(
nodeSearchEnabled,
(newVal) => {
LiteGraph.release_link_on_empty_shows_menu = !newVal
if (comfyApp.canvas) comfyApp.canvas.allow_searchbox = !newVal
},
{ immediate: true }
)
let dropTargetCleanup = () => {}
Expand Down
8 changes: 1 addition & 7 deletions src/components/searchbox/NodeSearchBoxPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { LiteGraphCanvasEvent, ConnectingLink } from '@comfyorg/litegraph'
import { FilterAndValue } from '@/services/nodeSearchService'
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
import { ConnectingLinkImpl } from '@/types/litegraphTypes'
import { LiteGraph } from '@comfyorg/litegraph'
interface LiteGraphPointerEvent extends Event {
canvasX: number
Expand Down Expand Up @@ -83,13 +84,6 @@ const addNode = (nodeDef: ComfyNodeDefImpl) => {
}
const canvasEventHandler = (e: LiteGraphCanvasEvent) => {
const shiftPressed = (e.detail.originalEvent as KeyboardEvent).shiftKey
// Ignore empty releases unless shift is pressed
// Empty release without shift is trigger right click menu
if (e.detail.subType === 'empty-release' && !shiftPressed) {
return
}
if (e.detail.subType === 'empty-release') {
const context = e.detail.linkReleaseContext
if (context.links.length === 0) {
Expand Down
1 change: 0 additions & 1 deletion src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,6 @@ export class ComfyApp {
this.canvas = new LGraphCanvas(canvasEl, this.graph)
this.ctx = canvasEl.getContext('2d')

LiteGraph.release_link_on_empty_shows_menu = true
LiteGraph.alt_drag_do_clone_nodes = true

this.graph.start()
Expand Down

0 comments on commit 4b83ee3

Please sign in to comment.