From 6670fd28f4d65c44d661dc3b59072cdcb31fd8c0 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Tue, 13 May 2025 11:45:13 +0800 Subject: [PATCH] Add sync functionality for clipStrength when collapsed in Loras widget. https://github.com/willmiao/ComfyUI-Lora-Manager/issues/176 --- web/comfyui/loras_widget.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/comfyui/loras_widget.js b/web/comfyui/loras_widget.js index 05283348..f411d3b5 100644 --- a/web/comfyui/loras_widget.js +++ b/web/comfyui/loras_widget.js @@ -399,6 +399,8 @@ export function addLorasWidget(node, name, opts, callback) { lorasData[loraIndex].clipStrength = newStrength; } else { lorasData[loraIndex].strength = newStrength; + // Sync clipStrength if collapsed + syncClipStrengthIfCollapsed(lorasData[loraIndex]); } // Update the widget value @@ -844,6 +846,8 @@ export function addLorasWidget(node, name, opts, callback) { if (loraIndex >= 0) { lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) - 0.05).toFixed(2); + // Sync clipStrength if collapsed + syncClipStrengthIfCollapsed(lorasData[loraIndex]); const newValue = formatLoraValue(lorasData); widget.value = newValue; @@ -906,6 +910,8 @@ export function addLorasWidget(node, name, opts, callback) { if (loraIndex >= 0) { lorasData[loraIndex].strength = newValue.toFixed(2); + // Sync clipStrength if collapsed + syncClipStrengthIfCollapsed(lorasData[loraIndex]); // Update value and trigger callback const newLorasValue = formatLoraValue(lorasData); @@ -928,6 +934,8 @@ export function addLorasWidget(node, name, opts, callback) { if (loraIndex >= 0) { lorasData[loraIndex].strength = (parseFloat(lorasData[loraIndex].strength) + 0.05).toFixed(2); + // Sync clipStrength if collapsed + syncClipStrengthIfCollapsed(lorasData[loraIndex]); const newValue = formatLoraValue(lorasData); widget.value = newValue; @@ -1284,4 +1292,13 @@ const shouldShowClipEntry = (loraData) => { } // Otherwise use the legacy logic - if values differ, it should be expanded return Number(loraData.strength) !== Number(loraData.clipStrength); -} \ No newline at end of file +} + +// Helper function to sync clipStrength with strength when collapsed +const syncClipStrengthIfCollapsed = (loraData) => { + // If not expanded (collapsed), sync clipStrength with strength + if (loraData.hasOwnProperty('expanded') && !loraData.expanded) { + loraData.clipStrength = loraData.strength; + } + return loraData; +}; \ No newline at end of file