Fix so that unneeded fields are also hidden on node creation

This commit is contained in:
Luis Quesada
2024-05-16 18:21:25 +02:00
parent dd346c3d58
commit 732e67d75a
+2 -3
View File
@@ -3,7 +3,7 @@ import { app } from "../../scripts/app.js";
// Some fragments of this code are from https://github.com/LucianoCirino/efficiency-nodes-comfyui
function inpaintCropHandler(node) {
if (node.type != "InpaintCrop") {
if (node.comfyClass != "InpaintCrop") {
return;
}
toggleWidget(node, findWidgetByName(node, "force_size"));
@@ -56,14 +56,13 @@ function toggleWidget(node, widget, show = false, suffix = "") {
app.registerExtension({
name: "inpaint-cropandstitch.showcontrol",
nodeCreated(node) {
inpaintCropHandler(node);
for (const w of node.widgets || []) {
let widgetValue = w.value;
// Store the original descriptor if it exists
let originalDescriptor = Object.getOwnPropertyDescriptor(w, 'value');
inpaintCropHandler(node);
Object.defineProperty(w, 'value', {
get() {
// If there's an original getter, use it. Otherwise, return widgetValue.