From b432b2411cbb7d3192d35953bd3aafea05a0e245 Mon Sep 17 00:00:00 2001 From: Luis Quesada Date: Sat, 10 May 2025 09:46:47 +0200 Subject: [PATCH] Super simplify widget hide logic, turn into disable, this fixes many quirks with the new frontend --- js/showcontrol.js | 28 ++-------------------------- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/js/showcontrol.js b/js/showcontrol.js index 39ef443..b7cbf69 100644 --- a/js/showcontrol.js +++ b/js/showcontrol.js @@ -105,39 +105,15 @@ function inpaintCropAndStitchHandler(node) { return; } -let origProps = {}; - const findWidgetByName = (node, name) => { return node.widgets ? node.widgets.find((w) => w.name === name) : null; }; -const doesInputWithNameExist = (node, name) => { - // See https://github.com/jags111/efficiency-nodes-comfyui/pull/315 - return false; -}; - -const HIDDEN_TAG = "tschide"; // Toggle Widget + change size function toggleWidget(node, widget, show = false, suffix = "") { - if (!widget || doesInputWithNameExist(node, widget.name)) return; - - // Store the original properties of the widget if not already stored - if (!origProps[widget.name]) { - origProps[widget.name] = { origType: widget.type, origComputeSize: widget.computeSize }; - } - - const origSize = node.size; - - // Set the widget type and computeSize based on the show flag - widget.type = show ? origProps[widget.name].origType : HIDDEN_TAG + suffix; - widget.computeSize = show ? origProps[widget.name].origComputeSize : () => [0, -4]; - - // Recursively handle linked widgets if they exist + if (!widget) return; + widget.disabled = !show widget.linkedWidgets?.forEach(w => toggleWidget(node, w, ":" + widget.name, show)); - - // Calculate the new height for the node based on its computeSize method - const newHeight = node.computeSize()[1]; - node.setSize([node.size[0], newHeight]); } app.registerExtension({ diff --git a/pyproject.toml b/pyproject.toml index 3eab901..96385aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-inpaint-cropandstitch" description = "The '✂️ Inpaint Crop' and '✂️ Inpaint Stitch' nodes enable inpainting only on masked area very easily: crop the image around the masked area with the Crop node, then use any standard workflow for sampling, then connect the sampled image to the Stitch node, which will put it back in place in the original image. These nodes enable faster sampling of smaller areas and take care of downsampling and upsampling to fit specific model and resource needs." -version = "2.1.6" +version = "2.1.7" license = { file = "LICENSE" } [project.urls]