Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions browser_tests/tests/vueNodes/interactions/node/resize.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {
comfyExpect as expect,
comfyPageFixture as test
} from '../../../../fixtures/ComfyPage'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think we should have a path for these


test.describe('Vue Node Resizing', () => {
test.beforeEach(async ({ comfyPage }) => {
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
await comfyPage.vueNodes.waitForNodes()
})

test('should resize node without position drift after selecting', async ({
comfyPage
}) => {
// Get a Vue node fixture
const node = await comfyPage.vueNodes.getFixtureByTitle('Load Checkpoint')
const initialBox = await node.boundingBox()
if (!initialBox) throw new Error('Node bounding box not found')

// Select the node first (this was causing the bug)
await node.header.click()
await comfyPage.page.waitForTimeout(100) // Brief pause after selection

// Get position after selection
const selectedBox = await node.boundingBox()
if (!selectedBox)
throw new Error('Node bounding box not found after select')

// Verify position unchanged after selection
expect(selectedBox.x).toBeCloseTo(initialBox.x, 1)
expect(selectedBox.y).toBeCloseTo(initialBox.y, 1)

// Now resize from bottom-right corner
const resizeStartX = selectedBox.x + selectedBox.width - 5
const resizeStartY = selectedBox.y + selectedBox.height - 5

await comfyPage.page.mouse.move(resizeStartX, resizeStartY)
await comfyPage.page.mouse.down()
await comfyPage.page.mouse.move(resizeStartX + 50, resizeStartY + 30)
await comfyPage.page.mouse.up()

// Get final position and size
const finalBox = await node.boundingBox()
if (!finalBox) throw new Error('Node bounding box not found after resize')

// Position should NOT have changed (the bug was position drift)
expect(finalBox.x).toBeCloseTo(initialBox.x, 1)
expect(finalBox.y).toBeCloseTo(initialBox.y, 1)

// Size should have increased
expect(finalBox.width).toBeGreaterThan(initialBox.width)
expect(finalBox.height).toBeGreaterThan(initialBox.height)
})
})
2 changes: 2 additions & 0 deletions src/renderer/core/layout/store/layoutStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class LayoutStoreImpl implements LayoutStore {

// Vue dragging state for selection toolbox (public ref for direct mutation)
public isDraggingVueNodes = ref(false)
// Vue resizing state to prevent drag from activating during resize
public isResizingVueNodes = ref(false)
Comment on lines 140 to +142
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?

Suggested change
public isDraggingVueNodes = ref(false)
// Vue resizing state to prevent drag from activating during resize
public isResizingVueNodes = ref(false)
public readonly isDraggingVueNodes = ref(false)
// Vue resizing state to prevent drag from activating during resize
public readonly isResizingVueNodes = ref(false)


constructor() {
// Initialize Yjs data structures
Expand Down
74 changes: 12 additions & 62 deletions src/renderer/extensions/vueNodes/components/LGraphNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,14 @@
</div>
</template>

<!-- Resize handles -->
<template v-if="!isCollapsed">
<div
v-for="handle in cornerResizeHandles"
:key="handle.id"
role="button"
:aria-label="handle.ariaLabel"
:class="cn(baseResizeHandleClasses, handle.classes)"
@pointerdown.stop="handleResizePointerDown(handle.direction)($event)"
/>
</template>
<!-- Resize handle (bottom-right only) -->
<div
v-if="!isCollapsed"
role="button"
:aria-label="t('g.resizeFromBottomRight')"
:class="cn(baseResizeHandleClasses, 'right-0 bottom-0 cursor-se-resize')"
@pointerdown.stop="handleResizePointerDown"
/>
</div>
</template>

Expand Down Expand Up @@ -171,7 +168,6 @@ import {
} from '@/utils/graphTraversalUtil'
import { cn } from '@/utils/tailwindUtil'

import type { ResizeHandleDirection } from '../interactions/resize/resizeMath'
import { useNodeResize } from '../interactions/resize/useNodeResize'
import LivePreview from './LivePreview.vue'
import NodeContent from './NodeContent.vue'
Expand Down Expand Up @@ -263,7 +259,7 @@ onErrorCaptured((error) => {
return false // Prevent error propagation
})

const { position, size, zIndex, moveNodeTo } = useNodeLayout(() => nodeData.id)
const { position, size, zIndex } = useNodeLayout(() => nodeData.id)
const { pointerHandlers } = useNodePointerInteractions(() => nodeData.id)
const { onPointerdown, ...remainingPointerHandlers } = pointerHandlers
const { startDrag } = useNodeDrag()
Expand Down Expand Up @@ -314,41 +310,6 @@ onMounted(() => {

const baseResizeHandleClasses =
'absolute h-3 w-3 opacity-0 pointer-events-auto focus-visible:outline focus-visible:outline-2 focus-visible:outline-white/40'
const POSITION_EPSILON = 0.01

type CornerResizeHandle = {
id: string
direction: ResizeHandleDirection
classes: string
ariaLabel: string
}

const cornerResizeHandles: CornerResizeHandle[] = [
{
id: 'se',
direction: { horizontal: 'right', vertical: 'bottom' },
classes: 'right-0 bottom-0 cursor-se-resize',
ariaLabel: t('g.resizeFromBottomRight')
},
{
id: 'ne',
direction: { horizontal: 'right', vertical: 'top' },
classes: 'right-0 top-0 cursor-ne-resize',
ariaLabel: t('g.resizeFromTopRight')
},
{
id: 'sw',
direction: { horizontal: 'left', vertical: 'bottom' },
classes: 'left-0 bottom-0 cursor-sw-resize',
ariaLabel: t('g.resizeFromBottomLeft')
},
{
id: 'nw',
direction: { horizontal: 'left', vertical: 'top' },
classes: 'left-0 top-0 cursor-nw-resize',
ariaLabel: t('g.resizeFromTopLeft')
}
]

const MIN_NODE_WIDTH = 225

Expand All @@ -361,22 +322,11 @@ const { startResize } = useNodeResize((result, element) => {
// Apply size directly to DOM element - ResizeObserver will pick this up
element.style.setProperty('--node-width', `${clampedWidth}px`)
element.style.setProperty('--node-height', `${result.size.height}px`)

const currentPosition = position.value
const deltaX = Math.abs(result.position.x - currentPosition.x)
const deltaY = Math.abs(result.position.y - currentPosition.y)

if (deltaX > POSITION_EPSILON || deltaY > POSITION_EPSILON) {
moveNodeTo(result.position)
}
})

const handleResizePointerDown = (direction: ResizeHandleDirection) => {
return (event: PointerEvent) => {
if (nodeData.flags?.pinned) return

startResize(event, direction, { ...position.value })
}
const handleResizePointerDown = (event: PointerEvent) => {
if (nodeData.flags?.pinned) return
startResize(event)
}

watch(isCollapsed, (collapsed) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
function onPointermove(event: PointerEvent) {
if (forwardMiddlePointerIfNeeded(event)) return

// Don't activate drag while resizing
if (layoutStore.isResizingVueNodes.value) return

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should select node immediately when drag starts

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:278:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should select node immediately when drag starts

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:278:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should select node immediately when drag starts

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:278:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should integrate with layout store dragging state

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:242:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should integrate with layout store dragging state

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:242:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should integrate with layout store dragging state

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:242:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should handle drag termination via cancel and context menu

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:194:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should handle drag termination via cancel and context menu

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:194:21

Check failure on line 67 in src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts

View workflow job for this annotation

GitHub Actions / test

src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts > useNodePointerInteractions > should handle drag termination via cancel and context menu

TypeError: Cannot read properties of undefined (reading 'value') ❯ Object.onPointermove src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.ts:67:40 ❯ src/renderer/extensions/vueNodes/composables/useNodePointerInteractions.test.ts:194:21

const nodeId = toValue(nodeIdRef)

if (nodeManager.value?.getNode(nodeId)?.flags?.pinned) {
Expand Down
104 changes: 0 additions & 104 deletions src/renderer/extensions/vueNodes/interactions/resize/resizeMath.ts

This file was deleted.

Loading
Loading