Repository navigation
feat: add Nodes 2.0 drag snapping #9894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fad0d17
feat: add nodes 2 drag snapping
benceruleanlu 8dd03d5
chore: satisfy drag snapping export usage
benceruleanlu 8c8143b
Fix snap guide pointer interaction test mock
benceruleanlu a5b517a
Update snapping setting version metadata
benceruleanlu 94fb623
Gate drag guides to vue mode
benceruleanlu 72381dc
Limit snap guide redraw to foreground
benceruleanlu 45f8ec3
Prune snap candidates by proximity
benceruleanlu 7c7eabb
fix: address drag snapping review feedback
benceruleanlu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
browser_tests/tests/vueNodes/interactions/node/dragSnapping.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| import { comfyPageFixture as test } from '../../../../fixtures/ComfyPage' | ||
|
|
||
| test.describe('Vue Node Drag Snapping', { tag: '@ui' }, () => { | ||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.settings.setSetting('Comfy.UseNewMenu', 'Disabled') | ||
| await comfyPage.settings.setSetting('Comfy.VueNodes.Enabled', true) | ||
| await comfyPage.workflow.loadWorkflow('default') | ||
| await comfyPage.canvasOps.resetView() | ||
| await comfyPage.vueNodes.waitForNodes(6) | ||
| }) | ||
|
|
||
| test('snaps a dragged node to another node in Vue nodes mode', async ({ | ||
| comfyPage | ||
| }) => { | ||
| await comfyPage.settings.setSetting( | ||
| 'Comfy.Canvas.AlignNodesWhileDragging', | ||
| true | ||
| ) | ||
|
|
||
| const ksamplerNode = comfyPage.vueNodes.getNodeByTitle('KSampler').first() | ||
| const checkpointNode = comfyPage.vueNodes | ||
| .getNodeByTitle('Load Checkpoint') | ||
| .first() | ||
| const ksamplerHeader = ksamplerNode.locator('.lg-node-header') | ||
|
|
||
| const ksamplerBox = await ksamplerNode.boundingBox() | ||
| const checkpointBox = await checkpointNode.boundingBox() | ||
| const headerBox = await ksamplerHeader.boundingBox() | ||
|
|
||
| if (!ksamplerBox || !checkpointBox || !headerBox) { | ||
| throw new Error('Expected Vue node bounding boxes to be available') | ||
| } | ||
|
|
||
| const dragStart = { | ||
| x: headerBox.x + headerBox.width / 2, | ||
| y: headerBox.y + headerBox.height / 2 | ||
| } | ||
| const targetLeft = checkpointBox.x + 5 | ||
| const dragTarget = { | ||
| x: dragStart.x + (targetLeft - ksamplerBox.x), | ||
| y: dragStart.y | ||
| } | ||
|
|
||
| await comfyPage.canvasOps.dragAndDrop(dragStart, dragTarget) | ||
|
|
||
| await expect | ||
| .poll(async () => { | ||
| const draggedBox = await ksamplerNode.boundingBox() | ||
| return draggedBox ? Math.round(draggedBox.x) : null | ||
| }) | ||
| .toBe(Math.round(checkpointBox.x)) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (non-blocking):
onContextmenu(line 166) callscleanupDragState()instead ofendDrag(), which meansstopShiftSynclisteners are never torn down. This is a pre-existing pattern, but this PR addsvueDragSnapGuidescleanup here without the correspondingendDragcall -- so the snap guides are cleared but shift listeners still leak. Would it make sense to callsafeDragEndhere (similar toonPointercancel) to clean up everything?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, added safeDragCancel there that wraps cancelDrag and cleanupDragState