Skip to content

Commit 038ed27

Browse files
christian-byrnegithub-actions
andauthored
fix Vue node dragging/moving on touch devices (#5896)
## Summary Enabled touch drag functionality on Vue nodes by adding CSS `touchAction: 'none'`. ## Changes - **What**: Added [`touchAction: 'none'`](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) CSS property to Vue nodes for touch device compatibility - **What**: Added Playwright tests for both desktop and mobile drag interactions ## Review Focus Touch event handling on various mobile browsers and pointer event compatibility across different devices. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5896-fix-Vue-node-dragging-moving-on-touch-devices-2806d73d365081578b02cd6714fd8fe0) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <[email protected]>
1 parent 139ae87 commit 038ed27

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import {
2+
type ComfyPage,
3+
comfyExpect as expect,
4+
comfyPageFixture as test
5+
} from '../../../../fixtures/ComfyPage'
6+
import type { Position } from '../../../../fixtures/types'
7+
8+
test.describe('Vue Node Moving', () => {
9+
test.beforeEach(async ({ comfyPage }) => {
10+
await comfyPage.setSetting('Comfy.VueNodes.Enabled', true)
11+
await comfyPage.vueNodes.waitForNodes()
12+
})
13+
14+
const getLoadCheckpointHeaderPos = async (comfyPage: ComfyPage) => {
15+
const loadCheckpointHeaderPos = await comfyPage.page
16+
.getByText('Load Checkpoint')
17+
.boundingBox()
18+
19+
if (!loadCheckpointHeaderPos)
20+
throw new Error('Load Checkpoint header not found')
21+
22+
return loadCheckpointHeaderPos
23+
}
24+
25+
const expectPosChanged = async (pos1: Position, pos2: Position) => {
26+
const diffX = Math.abs(pos2.x - pos1.x)
27+
const diffY = Math.abs(pos2.y - pos1.y)
28+
expect(diffX).toBeGreaterThan(0)
29+
expect(diffY).toBeGreaterThan(0)
30+
}
31+
32+
test('should allow moving nodes by dragging', async ({ comfyPage }) => {
33+
const loadCheckpointHeaderPos = await getLoadCheckpointHeaderPos(comfyPage)
34+
await comfyPage.dragAndDrop(loadCheckpointHeaderPos, {
35+
x: 256,
36+
y: 256
37+
})
38+
39+
const newHeaderPos = await getLoadCheckpointHeaderPos(comfyPage)
40+
await expectPosChanged(loadCheckpointHeaderPos, newHeaderPos)
41+
42+
await expect(comfyPage.canvas).toHaveScreenshot('vue-node-moved-node.png')
43+
})
44+
45+
test('@mobile should allow moving nodes by dragging on touch devices', async ({
46+
comfyPage
47+
}) => {
48+
// Disable minimap (gets in way of the node on small screens)
49+
await comfyPage.setSetting('Comfy.Minimap.Visible', false)
50+
51+
const loadCheckpointHeaderPos = await getLoadCheckpointHeaderPos(comfyPage)
52+
await comfyPage.panWithTouch(
53+
{
54+
x: 64,
55+
y: 64
56+
},
57+
loadCheckpointHeaderPos
58+
)
59+
60+
const newHeaderPos = await getLoadCheckpointHeaderPos(comfyPage)
61+
await expectPosChanged(loadCheckpointHeaderPos, newHeaderPos)
62+
63+
await expect(comfyPage.canvas).toHaveScreenshot(
64+
'vue-node-moved-node-touch.png'
65+
)
66+
})
67+
})
73.9 KB
Loading
9.17 KB
Loading

src/renderer/extensions/vueNodes/components/LGraphNode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:class="
1010
cn(
1111
'bg-white dark-theme:bg-charcoal-800',
12-
'lg-node absolute rounded-2xl',
12+
'lg-node absolute rounded-2xl touch-none',
1313
'border-2 border-solid border-sand-100 dark-theme:border-charcoal-600',
1414
// hover (only when node should handle events)
1515
shouldHandleNodePointerEvents &&

0 commit comments

Comments
 (0)