From 454210a47c3aee30c877ab5da23d9faa978f9ee3 Mon Sep 17 00:00:00 2001 From: hein Date: Mon, 4 May 2026 22:40:30 +0800 Subject: [PATCH] fix: commit dragged strength through options.setValue at drag end During drag, handleStrengthDrag is called with updateWidget=false, which mutates widgetValue in-place via parseLoraValue's direct array reference, bypassing widget.value setter and options.setValue entirely. endDrag only called renderFunction for a DOM refresh, but never flushed the mutation through options.setValue. Any external observer that wraps options.setValue (e.g. ComfyUI Mirror Panel's bidirectional sync) would therefore never see the dragged value and would treat the widget as unchanged. Fix: replace the explicit renderFunction call with widget.value = widget.value. This flushes the in-place mutation through the setter (options.setValue), which re-renders the DOM internally AND notifies all setValue wrappers. Also fire widget.callback for parity with the updateWidget=true path in handleStrengthDrag. Applies the same fix to initHeaderDrag (proportional all-LoRA header drag). --- web/comfyui/loras_widget_events.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/web/comfyui/loras_widget_events.js b/web/comfyui/loras_widget_events.js index 63f30c08..5e927e27 100644 --- a/web/comfyui/loras_widget_events.js +++ b/web/comfyui/loras_widget_events.js @@ -232,9 +232,13 @@ export function initDrag( onDragEnd(); } - // Now do the re-render after drag is complete - if (renderFunction) { - renderFunction(widget.value, widget); + // Commit final value through options.setValue so external observers are notified. + // During drag, handleStrengthDrag mutates widgetValue in-place (updateWidget=false), + // bypassing widget.value setter and options.setValue entirely. This assignment + // flushes the in-place mutation through the setter so any setValue wrappers fire. + widget.value = widget.value; + if (typeof widget.callback === 'function') { + widget.callback(widget.value); } } }; @@ -349,11 +353,15 @@ export function initHeaderDrag(headerEl, widget, renderFunction) { document.body.classList.remove('lm-lora-strength-dragging'); // Only re-render if we actually dragged - if (wasDragging && renderFunction) { - renderFunction(widget.value, widget); + if (wasDragging) { + // Commit final value through options.setValue so external observers are notified. + widget.value = widget.value; + if (typeof widget.callback === 'function') { + widget.callback(widget.value); + } } }; - + // Handle pointer up to end dragging headerEl.addEventListener('pointerup', endDrag);