mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 12:52:10 -03:00
Add DOM connection check to prevent capturing events in subgraphs
Ensure the canvas element is actually connected to the DOM before handling paste events. This prevents LayerForge from capturing paste events when navigating in subgraphs where the canvas is not visible. Adds check for canvas.isConnected and document.body.contains() to verify the canvas is part of the active DOM tree.
This commit is contained in:
@@ -1165,6 +1165,10 @@ export class CanvasInteractions {
|
||||
}
|
||||
}
|
||||
async handlePasteEvent(e) {
|
||||
// Check if canvas is connected to DOM and visible
|
||||
if (!this.canvas.canvas.isConnected || !document.body.contains(this.canvas.canvas)) {
|
||||
return;
|
||||
}
|
||||
const shouldHandle = this.canvas.isMouseOver ||
|
||||
this.canvas.canvas.contains(document.activeElement) ||
|
||||
document.activeElement === this.canvas.canvas;
|
||||
|
||||
@@ -1354,6 +1354,10 @@ export class CanvasInteractions {
|
||||
}
|
||||
|
||||
async handlePasteEvent(e: ClipboardEvent): Promise<void> {
|
||||
// Check if canvas is connected to DOM and visible
|
||||
if (!this.canvas.canvas.isConnected || !document.body.contains(this.canvas.canvas)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const shouldHandle = this.canvas.isMouseOver ||
|
||||
this.canvas.canvas.contains(document.activeElement) ||
|
||||
|
||||
Reference in New Issue
Block a user