From 98d4769ba146969d2dc6b05bec130d75ef55e133 Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Mon, 21 Jul 2025 20:45:13 +0200 Subject: [PATCH] Fix preview visibility initialization in Canvas Replaces setPreviewVisibility(false) with direct assignment to previewVisible in Canvas and Canvas.ts. Adds initialization of preview state based on widget value in CanvasView and CanvasView.ts to ensure correct preview visibility on widget creation. --- js/Canvas.js | 2 +- js/CanvasView.js | 4 ++++ src/Canvas.ts | 2 +- src/CanvasView.ts | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/js/Canvas.js b/js/Canvas.js index c077851..25423cd 100644 --- a/js/Canvas.js +++ b/js/Canvas.js @@ -83,7 +83,7 @@ export class Canvas { dimensions: { width: this.width, height: this.height }, viewport: this.viewport }); - this.setPreviewVisibility(false); + this.previewVisible = false; } async waitForWidget(name, node, interval = 100, timeout = 20000) { const startTime = Date.now(); diff --git a/js/CanvasView.js b/js/CanvasView.js index c7513fb..e83da84 100644 --- a/js/CanvasView.js +++ b/js/CanvasView.js @@ -667,6 +667,10 @@ async function createCanvasWidget(node, widget, app) { node.setDirtyCanvas(true, true); } }; + // Inicjalizuj stan preview na podstawie aktualnej wartości widget'u + if (canvas && canvas.setPreviewVisibility) { + canvas.setPreviewVisibility(showPreviewWidget.value); + } } return { canvas: canvas, diff --git a/src/Canvas.ts b/src/Canvas.ts index 9cadfc3..944bc34 100644 --- a/src/Canvas.ts +++ b/src/Canvas.ts @@ -132,7 +132,7 @@ export class Canvas { viewport: this.viewport }); - this.setPreviewVisibility(false); + this.previewVisible = false; } diff --git a/src/CanvasView.ts b/src/CanvasView.ts index 595e878..3ad4878 100644 --- a/src/CanvasView.ts +++ b/src/CanvasView.ts @@ -730,6 +730,11 @@ async function createCanvasWidget(node: ComfyNode, widget: any, app: ComfyApp): node.setDirtyCanvas(true, true); } }; + + // Inicjalizuj stan preview na podstawie aktualnej wartości widget'u + if (canvas && canvas.setPreviewVisibility) { + canvas.setPreviewVisibility(showPreviewWidget.value); + } } return {