From a562ba374614777ece28e4bb65c5acba7613b05c Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Thu, 15 May 2025 10:30:46 +0800 Subject: [PATCH] Fix TriggerWord Toggle not updating when all LoRAs are disabled --- web/comfyui/lora_loader.js | 18 ++++++------------ web/comfyui/utils.js | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/web/comfyui/lora_loader.js b/web/comfyui/lora_loader.js index 1926d5b2..f8ee7332 100644 --- a/web/comfyui/lora_loader.js +++ b/web/comfyui/lora_loader.js @@ -114,6 +114,12 @@ app.registerExtension({ const result = addLorasWidget(node, "loras", { defaultVal: mergedLoras // Pass object directly }, (value) => { + // Collect all active loras from this node and its input chain + const allActiveLoraNames = collectActiveLorasFromChain(node); + + // Update trigger words for connected toggle nodes with the aggregated lora names + updateConnectedTriggerWords(node, allActiveLoraNames); + // Prevent recursive calls if (isUpdating) return; isUpdating = true; @@ -132,12 +138,6 @@ app.registerExtension({ newText = newText.replace(/\s+/g, ' ').trim(); inputWidget.value = newText; - - // Collect all active loras from this node and its input chain - const allActiveLoraNames = collectActiveLorasFromChain(node); - - // Update trigger words for connected toggle nodes with the aggregated lora names - updateConnectedTriggerWords(node, allActiveLoraNames); } finally { isUpdating = false; } @@ -156,12 +156,6 @@ app.registerExtension({ const mergedLoras = mergeLoras(value, currentLoras); node.lorasWidget.value = mergedLoras; - - // Collect all active loras from this node and its input chain - const allActiveLoraNames = collectActiveLorasFromChain(node); - - // Update trigger words for connected toggle nodes with the aggregated lora names - updateConnectedTriggerWords(node, allActiveLoraNames); } finally { isUpdating = false; } diff --git a/web/comfyui/utils.js b/web/comfyui/utils.js index 9fcebb7d..9fe00f9a 100644 --- a/web/comfyui/utils.js +++ b/web/comfyui/utils.js @@ -155,7 +155,7 @@ export function collectActiveLorasFromChain(node, visited = new Set()) { // Update trigger words for connected toggle nodes export function updateConnectedTriggerWords(node, loraNames) { const connectedNodeIds = getConnectedTriggerToggleNodes(node); - if (connectedNodeIds.length > 0 && loraNames.size > 0) { + if (connectedNodeIds.length > 0) { fetch("/loramanager/get_trigger_words", { method: "POST", headers: { "Content-Type": "application/json" },