fix: use node.pos/size instead of getBounding for positioning

getBounding returns stale data for freshly created nodes since
updateArea only runs at the start of each render frame. Use
node.pos and node.size directly which are set immediately by
createNode.
This commit is contained in:
bymyself
2026-03-15 10:37:43 +00:00
parent 959f1365dd
commit 75022f302b
2 changed files with 8 additions and 6 deletions

View File

@@ -207,7 +207,7 @@ describe('ComfyApp', () => {
it('should position batch node to the right of first node', () => {
const mockNode1 = createMockNode({
pos: [100, 200],
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
size: [300, 400]
})
const mockBatchNode = createMockNode({ pos: [0, 0] })
@@ -219,8 +219,8 @@ describe('ComfyApp', () => {
it('should stack multiple image nodes vertically', () => {
const mockNode1 = createMockNode({
pos: [100, 200],
type: 'LoadImage',
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
size: [300, 400],
type: 'LoadImage'
})
const mockNode2 = createMockNode({ pos: [0, 0], type: 'LoadImage' })
const mockNode3 = createMockNode({ pos: [0, 0], type: 'LoadImage' })
@@ -235,7 +235,8 @@ describe('ComfyApp', () => {
it('should call graph change once for all nodes', () => {
const mockNode1 = createMockNode({
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
pos: [100, 200],
size: [300, 400]
})
const mockBatchNode = createMockNode()

View File

@@ -1782,8 +1782,9 @@ export class ComfyApp {
}
positionBatchNodes(nodes: LGraphNode[], batchNode: LGraphNode): void {
const [x, y, width] = nodes[0].getBounding()
batchNode.pos = [x + width + 100, y + 30]
const [x, y] = nodes[0].pos
const nodeWidth = nodes[0].size[0]
batchNode.pos = [x + nodeWidth + 100, y + 30]
// Retrieving Node Height is inconsistent
let height = 0