Skip to content

Commit 0481560

Browse files
authored
Fix two undo steps on add node via context menu (#3674)
1 parent c7435af commit 0481560

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/components/searchbox/NodeSearchBoxPopover.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { useLitegraphService } from '@/services/litegraphService'
4949
import { useCanvasStore } from '@/stores/graphStore'
5050
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
5151
import { useSettingStore } from '@/stores/settingStore'
52+
import { useWorkflowStore } from '@/stores/workflowStore'
5253
import { useSearchBoxStore } from '@/stores/workspace/searchBoxStore'
5354
import { LinkReleaseTriggerAction } from '@/types/searchBoxTypes'
5455
import { FuseFilterWithValue } from '@/utils/fuseUtil'
@@ -101,6 +102,8 @@ const addNode = (nodeDef: ComfyNodeDefImpl) => {
101102
102103
canvasStore.getCanvas().linkConnector.connectToNode(node, triggerEvent)
103104
105+
// Notify changeTracker - new step should be added
106+
useWorkflowStore().activeWorkflow?.changeTracker?.checkState()
104107
window.requestAnimationFrame(closeDialog)
105108
}
106109

src/scripts/changeTracker.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { LGraphCanvas, LiteGraph } from '@comfyorg/litegraph'
2-
import { LGraphNode } from '@comfyorg/litegraph'
32
import * as jsondiffpatch from 'jsondiffpatch'
43
import _ from 'lodash'
54
import log from 'loglevel'
@@ -301,17 +300,6 @@ export class ChangeTracker {
301300
return v
302301
}
303302

304-
// Detects nodes being added via the node search dialog
305-
const onNodeAdded = LiteGraph.LGraph.prototype.onNodeAdded
306-
LiteGraph.LGraph.prototype.onNodeAdded = function (node: LGraphNode) {
307-
const v = onNodeAdded?.apply(this, [node])
308-
if (!app?.configuringGraph) {
309-
logger.debug('checkState on onNodeAdded')
310-
checkState()
311-
}
312-
return v
313-
}
314-
315303
// Handle multiple commands as a single transaction
316304
document.addEventListener('litegraph:canvas', (e: Event) => {
317305
const detail = (e as CustomEvent).detail

0 commit comments

Comments
 (0)