mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 00:20:07 +00:00
Fix render issues after moving floating input links (#841)
- Fixes floating inputs have invisible segment after moving - Fixes floating input can be moved onto existing input link, resulting in the slot having two links
This commit is contained in:
@@ -96,12 +96,12 @@ export class FloatingRenderLink implements RenderLink {
|
||||
this.fromPos = fromReroute.pos
|
||||
}
|
||||
|
||||
canConnectToInput(): true {
|
||||
return true
|
||||
canConnectToInput(): boolean {
|
||||
return this.toType === "input"
|
||||
}
|
||||
|
||||
canConnectToOutput(): true {
|
||||
return true
|
||||
canConnectToOutput(): boolean {
|
||||
return this.toType === "output"
|
||||
}
|
||||
|
||||
canConnectToReroute(reroute: Reroute): boolean {
|
||||
@@ -118,6 +118,8 @@ export class FloatingRenderLink implements RenderLink {
|
||||
floatingLink.target_id = node.id
|
||||
floatingLink.target_slot = node.inputs.indexOf(input)
|
||||
|
||||
node.disconnectInput(node.inputs.indexOf(input))
|
||||
|
||||
this.fromSlot._floatingLinks?.delete(floatingLink)
|
||||
input._floatingLinks ??= new Set()
|
||||
input._floatingLinks.add(floatingLink)
|
||||
|
||||
@@ -622,6 +622,7 @@ export class LinkConnector {
|
||||
|
||||
for (const link of outputLinks) delete link._dragging
|
||||
for (const link of inputLinks) delete link._dragging
|
||||
for (const link of floatingLinks) delete link._dragging
|
||||
for (const reroute of hiddenReroutes) delete reroute._dragging
|
||||
|
||||
renderLinks.length = 0
|
||||
|
||||
@@ -530,6 +530,27 @@ describe("LinkConnector Integration", () => {
|
||||
|
||||
validateIntegrityFloatingRemoved()
|
||||
})
|
||||
|
||||
test("Dropping a floating input link onto input slot disconnects the existing link", ({ graph, connector }) => {
|
||||
const manyOutputsNode = graph.getNodeById(4)!
|
||||
manyOutputsNode.disconnectOutput(0)
|
||||
|
||||
const floatingInputNode = graph.getNodeById(6)!
|
||||
const fromFloatingInput = floatingInputNode.inputs[0]
|
||||
|
||||
const hasInputNode = graph.getNodeById(2)!
|
||||
const toInput = hasInputNode.inputs[0]
|
||||
|
||||
connector.moveInputLink(graph, fromFloatingInput)
|
||||
const dropEvent = mockedInputDropEvent(hasInputNode, 0)
|
||||
connector.dropLinks(graph, dropEvent)
|
||||
|
||||
expect(fromFloatingInput.link).toBeNull()
|
||||
expect(fromFloatingInput._floatingLinks?.size).toBe(0)
|
||||
|
||||
expect(toInput.link).toBeNull()
|
||||
expect(toInput._floatingLinks?.size).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
test("Should drop floating links when both sides are disconnected", ({ graph, connector, reroutesBeforeTest, validateIntegrityNoChanges }) => {
|
||||
|
||||
Reference in New Issue
Block a user