Skip to content

Commit 838acef

Browse files
authored
Fix graph.change called twice on keypress (#3695)
1 parent df723b5 commit 838acef

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/scripts/app.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,7 @@ export class ComfyApp {
507507
#addProcessKeyHandler() {
508508
const origProcessKey = LGraphCanvas.prototype.processKey
509509
LGraphCanvas.prototype.processKey = function (e: KeyboardEvent) {
510-
if (!this.graph) {
511-
return
512-
}
513-
514-
var block_default = false
510+
if (!this.graph) return
515511

516512
if (e.target instanceof Element && e.target.localName == 'input') {
517513
return
@@ -521,15 +517,19 @@ export class ComfyApp {
521517
const keyCombo = KeyComboImpl.fromEvent(e)
522518
const keybindingStore = useKeybindingStore()
523519
const keybinding = keybindingStore.getKeybinding(keyCombo)
520+
524521
if (keybinding && keybinding.targetElementId === 'graph-canvas') {
525522
useCommandStore().execute(keybinding.commandId)
526-
block_default = true
523+
524+
this.graph.change()
525+
e.preventDefault()
526+
e.stopImmediatePropagation()
527+
return
527528
}
528529

529530
// Ctrl+C Copy
530531
if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
531-
// Trigger onCopy
532-
return true
532+
return
533533
}
534534

535535
// Ctrl+V Paste
@@ -538,19 +538,10 @@ export class ComfyApp {
538538
(e.metaKey || e.ctrlKey) &&
539539
!e.shiftKey
540540
) {
541-
// Trigger onPaste
542-
return true
541+
return
543542
}
544543
}
545544

546-
this.graph.change()
547-
548-
if (block_default) {
549-
e.preventDefault()
550-
e.stopImmediatePropagation()
551-
return false
552-
}
553-
554545
// Fall through to Litegraph defaults
555546
// @ts-expect-error fixme ts strict error
556547
return origProcessKey.apply(this, arguments)

0 commit comments

Comments
 (0)