mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 06:47:33 +00:00
This pull request refactors the node selection logic in the Vue nodes event handler composable to simplify the function signature and improve single vs. multi-selection behavior. The main change is the removal of the `wasDragging` parameter from the `handleNodeSelect` function, with selection logic now determined by the current selection state. Related test code is updated to match the new function signature. **Node selection logic improvements:** * Refactored the `handleNodeSelect` function in `useNodeEventHandlersIndividual` to remove the `wasDragging` parameter, making the function signature simpler and relying on selection state to handle single vs. multi-selection. * Updated the selection logic to check if multiple nodes are already selected using `isLGraphNode`, and only perform single selection if not. **Code and test updates:** * Updated all calls to `handleNodeSelect` in the composable to remove the `wasDragging` argument, ensuring consistent usage throughout the codebase. [[1]](diffhunk://#diff-8d3820a1ca9c569bce00671fdd6290af81315ae11b8f3d6f29a5a9d30379d084L125-R123) [[2]](diffhunk://#diff-8d3820a1ca9c569bce00671fdd6290af81315ae11b8f3d6f29a5a9d30379d084L146-R144) [[3]](diffhunk://#diff-8d3820a1ca9c569bce00671fdd6290af81315ae11b8f3d6f29a5a9d30379d084L173-R171) * Updated all related test cases to use the new `handleNodeSelect` signature without the third parameter. [[1]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL105-R105) [[2]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL125-R125) [[3]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL144-R144) [[4]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL162-R162) [[5]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL174-R174) [[6]](diffhunk://#diff-89bfc2a05201c6ff7116578efa45f96097594eb346f18446c70aa7125ab1811aL187-R187) **Utility import:** * Added an import for `isLGraphNode` from `@/utils/litegraphUtil` to support the updated selection logic.## Summary <!-- One sentence describing what changed and why. --> ## Screenshots (if applicable) https://github.com/user-attachments/assets/71e856d3-afc2-497d-826e-5b485066e7fe --------- Co-authored-by: github-actions <github-actions@github.com>
85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
import {
|
|
comfyExpect as expect,
|
|
comfyPageFixture as test
|
|
} from '../../../../fixtures/ComfyPage'
|
|
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.setSetting('Comfy.UseNewMenu', 'Disabled')
|
|
})
|
|
|
|
test.describe('Vue Node Selection', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
|
|
await comfyPage.vueNodes.waitForNodes()
|
|
})
|
|
|
|
const modifiers = [
|
|
{ key: 'Control', name: 'ctrl' },
|
|
{ key: 'Shift', name: 'shift' },
|
|
{ key: 'Meta', name: 'meta' }
|
|
] as const
|
|
|
|
for (const { key: modifier, name } of modifiers) {
|
|
test(`should allow selecting multiple nodes with ${name}+click`, async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.page.getByText('Load Checkpoint').click()
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(1)
|
|
|
|
await comfyPage.page.getByText('Empty Latent Image').click({
|
|
modifiers: [modifier]
|
|
})
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(2)
|
|
|
|
await comfyPage.page.getByText('KSampler').click({
|
|
modifiers: [modifier]
|
|
})
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(3)
|
|
})
|
|
|
|
test(`should allow de-selecting nodes with ${name}+click`, async ({
|
|
comfyPage
|
|
}) => {
|
|
await comfyPage.page.getByText('Load Checkpoint').click()
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(1)
|
|
|
|
await comfyPage.page.getByText('Load Checkpoint').click({
|
|
modifiers: [modifier]
|
|
})
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(0)
|
|
})
|
|
}
|
|
|
|
test('should select pinned node without dragging', async ({ comfyPage }) => {
|
|
const PIN_HOTKEY = 'p'
|
|
const PIN_INDICATOR = '[data-testid="node-pin-indicator"]'
|
|
|
|
// Select a node by clicking its title
|
|
const checkpointNodeHeader = comfyPage.page.getByText('Load Checkpoint')
|
|
await checkpointNodeHeader.click()
|
|
|
|
// Pin it using the hotkey (as a user would)
|
|
await comfyPage.page.keyboard.press(PIN_HOTKEY)
|
|
|
|
const checkpointNode = comfyPage.vueNodes.getNodeByTitle('Load Checkpoint')
|
|
const pinIndicator = checkpointNode.locator(PIN_INDICATOR)
|
|
await expect(pinIndicator).toBeVisible()
|
|
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(1)
|
|
|
|
const initialPos = await checkpointNodeHeader.boundingBox()
|
|
if (!initialPos) throw new Error('Failed to get header position')
|
|
|
|
await comfyPage.dragAndDrop(
|
|
{ x: initialPos.x + 10, y: initialPos.y + 10 },
|
|
{ x: initialPos.x + 100, y: initialPos.y + 100 }
|
|
)
|
|
|
|
const finalPos = await checkpointNodeHeader.boundingBox()
|
|
if (!finalPos) throw new Error('Failed to get header position after drag')
|
|
expect(finalPos).toEqual(initialPos)
|
|
|
|
expect(await comfyPage.vueNodes.getSelectedNodeCount()).toBe(1)
|
|
})
|
|
})
|