diff --git a/web/comfyui/lora_loader.js b/web/comfyui/lora_loader.js index 07fdf8b5..9d7ef728 100644 --- a/web/comfyui/lora_loader.js +++ b/web/comfyui/lora_loader.js @@ -89,15 +89,13 @@ app.registerExtension({ node.lorasWidget = result.widget; - // get the input widget and set a callback + // Update input widget callback const inputWidget = node.widgets[0]; inputWidget.callback = (value) => { - // Prevent recursive calls if (isUpdating) return; isUpdating = true; try { - // Merge the loras data with widget value const currentLoras = node.lorasWidget.value || []; const mergedLoras = mergeLoras(value, currentLoras); diff --git a/web/comfyui/loras_widget.js b/web/comfyui/loras_widget.js index f99ef6fd..04bd540f 100644 --- a/web/comfyui/loras_widget.js +++ b/web/comfyui/loras_widget.js @@ -666,13 +666,23 @@ export function addLorasWidget(node, name, opts, callback) { setValue: function(v) { widgetValue = v || ""; renderLoras(widgetValue, widget); + + // Update container height after rendering + requestAnimationFrame(() => { + const minHeight = this.getMinHeight(); + container.style.height = `${minHeight}px`; + + // Force node to update size + node.setSize([node.size[0], node.computeSize()[1]]); + node.setDirtyCanvas(true, true); + }); }, - getHeight: function() { + getMinHeight: function() { // Calculate height based on content const lorasCount = parseLoraValue(widgetValue).length; return Math.max( 100, - lorasCount > 0 ? 60 + lorasCount * 44 : 60 // Header + entries or minimum height + lorasCount > 0 ? 60 + lorasCount * 44 : 60 ); }, }); diff --git a/web/comfyui/tags_widget.js b/web/comfyui/tags_widget.js index 75dba7d1..663d5302 100644 --- a/web/comfyui/tags_widget.js +++ b/web/comfyui/tags_widget.js @@ -5,7 +5,7 @@ export function addTagsWidget(node, name, opts, callback) { Object.assign(container.style, { display: "flex", flexWrap: "wrap", - gap: "8px", + gap: "4px", // 从8px减小到4px padding: "6px", minHeight: "30px", backgroundColor: "rgba(40, 44, 52, 0.6)", // Darker, more modern background @@ -54,7 +54,7 @@ export function addTagsWidget(node, name, opts, callback) { // Helper function to update tag style based on active state function updateTagStyle(tagEl, active) { const baseStyles = { - padding: "6px 12px", // 水平内边距从16px减小到12px + padding: "4px 12px", // 垂直内边距从6px减小到4px borderRadius: "6px", // Matching container radius maxWidth: "200px", // Increased max width overflow: "hidden", @@ -66,7 +66,7 @@ export function addTagsWidget(node, name, opts, callback) { border: "1px solid transparent", display: "inline-block", boxShadow: "0 1px 2px rgba(0,0,0,0.1)", - margin: "4px", // 从6px减小到4px + margin: "2px", // 从4px减小到2px userSelect: "none", // Add this line to prevent text selection WebkitUserSelect: "none", // For Safari support MozUserSelect: "none", // For Firefox support @@ -112,12 +112,22 @@ export function addTagsWidget(node, name, opts, callback) { setValue: function(v) { widgetValue = v; renderTags(widgetValue, widget); + + // Update container height after rendering + requestAnimationFrame(() => { + const minHeight = this.getMinHeight(); + container.style.height = `${minHeight}px`; + + // Force node to update size + node.setSize([node.size[0], node.computeSize()[1]]); + node.setDirtyCanvas(true, true); + }); }, - getHeight: function() { + getMinHeight: function() { // Calculate height based on content return Math.max( 150, - Math.ceil(container.scrollHeight / 5) * 5 // Round up to nearest 5px + Math.ceil(container.scrollHeight / 5) * 5 + 15// Round up to nearest 5px ); }, }); diff --git a/web/comfyui/trigger_word_toggle.js b/web/comfyui/trigger_word_toggle.js index 360f05b4..40474c96 100644 --- a/web/comfyui/trigger_word_toggle.js +++ b/web/comfyui/trigger_word_toggle.js @@ -53,9 +53,6 @@ app.registerExtension({ if (typeof message === 'string') { // Get existing tags to preserve active states const existingTags = node.tagWidget.value || []; - - const tempWidget = node.tagWidget; - const originalHeight = tempWidget.options.getHeight(); // Create a map of existing tags and their active states const existingTagMap = {}; @@ -75,8 +72,6 @@ app.registerExtension({ })); node.tagWidget.value = tagArray; - node.size[1] = node.size[1] + (tempWidget.options.getHeight() - originalHeight); - node.setDirtyCanvas(true, true); } } },