fix(widgets): persist LoRA entry selection and active tab across save/load

This commit is contained in:
Will Miao
2026-07-17 18:26:30 +08:00
parent 090e0297d4
commit 681cc13e90
5 changed files with 121 additions and 70 deletions

View File

@@ -711,7 +711,11 @@ export function addLorasWidget(node, name, opts, callback) {
// Create widget with new DOM Widget API
const widget = node.addDOMWidget(name, "custom", container, {
getValue: function() {
return widgetValue;
return widgetValue.map(lora => {
const entry = { ...lora };
entry.selected = lora.name === selectedLora;
return entry;
});
},
setValue: function(v) {
// Remove duplicates by keeping the last occurrence of each lora name
@@ -738,6 +742,15 @@ export function addLorasWidget(node, name, opts, callback) {
});
widgetValue = updatedValue;
// Restore selection state when loading a saved workflow
if (!selectedLora) {
const selectedEntry = updatedValue.find(lora => lora.selected);
if (selectedEntry) {
selectedLora = selectedEntry.name;
}
}
renderLoras(widgetValue, widget);
},
hideOnZoom: true,