Fix ComfyUI shortcut leaks in LayerForge

Technical details:
- skip LayerForge canvas and panel shortcuts when focus is inside editable controls
- patch ComfyUI ChangeTracker undoRedo so Ctrl/Cmd+Z does not leak to graph history while LayerForge owns the shortcut context
- stop clipboard copy/cut/paste events from editable LayerForge UI from bubbling into ComfyUI node clipboard handlers
- route widget-root Ctrl/Cmd+Z, Ctrl/Cmd+Y, and Ctrl/Cmd+Shift+Z through LayerForge canvas undo and redo when the widget is active
This commit is contained in:
diodiogod
2026-03-18 00:32:31 -03:00
parent 835d94a11d
commit 1edde25d75
6 changed files with 331 additions and 2 deletions

View File

@@ -163,6 +163,19 @@ export class CanvasInteractions {
}
}
private isEditableElement(target: EventTarget | null): boolean {
if (!(target instanceof HTMLElement)) {
return false;
}
if (target.isContentEditable) {
return true;
}
const editableSelector = 'input, textarea, select, [contenteditable="true"]';
return !!target.closest(editableSelector);
}
setupEventListeners(): void {
this.canvas.canvas.addEventListener('mousedown', this.onMouseDown as EventListener);
this.canvas.canvas.addEventListener('mousemove', this.onMouseMove as EventListener);
@@ -666,6 +679,10 @@ export class CanvasInteractions {
if (e.key === 'Shift') this.interaction.isShiftPressed = true;
if (e.key === 'Alt') this.interaction.isAltPressed = true;
if (this.isEditableElement(e.target) || this.isEditableElement(document.activeElement)) {
return;
}
// Check if canvas is focused before handling any shortcuts
const shouldHandle = this.canvas.isMouseOver ||
this.canvas.canvas.contains(document.activeElement) ||