Fixes for combo node default value
This commit is contained in:
@@ -821,13 +821,15 @@ export default class ComfyApp {
|
|||||||
.flatMap(i => node.getInputSlotsConnectedTo(i))
|
.flatMap(i => node.getInputSlotsConnectedTo(i))
|
||||||
.find(inp => "config" in inp && Array.isArray((inp.config as any).values))
|
.find(inp => "config" in inp && Array.isArray((inp.config as any).values))
|
||||||
|
|
||||||
|
let defaultValue = null;
|
||||||
if (foundInput != null) {
|
if (foundInput != null) {
|
||||||
const comfyInput = foundInput as IComfyInputSlot;
|
const comfyInput = foundInput as IComfyInputSlot;
|
||||||
console.warn("[refreshComboInNodes] found frontend config:", node.title, node.type, comfyInput.config.values)
|
console.warn("[refreshComboInNodes] found frontend config:", node.title, node.type, comfyInput.config.values)
|
||||||
values = comfyInput.config.values;
|
values = comfyInput.config.values;
|
||||||
|
defaultValue = comfyInput.config.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
comboNode.formatValues(values);
|
comboNode.formatValues(values, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
@@ -842,7 +844,7 @@ export default class ComfyApp {
|
|||||||
|
|
||||||
comboNode.formatValues(rawValues as string[], true)
|
comboNode.formatValues(rawValues as string[], true)
|
||||||
if (!rawValues?.includes(get(comboNode.value))) {
|
if (!rawValues?.includes(get(comboNode.value))) {
|
||||||
comboNode.setValue(rawValues[0])
|
comboNode.setValue(rawValues[0], comfyInput.config.defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default class ComfyValueControl extends ComfyGraphNode {
|
|||||||
override properties: ComfyValueControlProperties = {
|
override properties: ComfyValueControlProperties = {
|
||||||
tags: [],
|
tags: [],
|
||||||
value: null,
|
value: null,
|
||||||
action: "fixed",
|
action: "randomize",
|
||||||
min: -INT_MAX,
|
min: -INT_MAX,
|
||||||
max: INT_MAX,
|
max: INT_MAX,
|
||||||
step: 1,
|
step: 1,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
formatValues(values: string[], lightUp: boolean = false) {
|
formatValues(values: string[], defaultValue?: string, lightUp: boolean = false) {
|
||||||
if (values == null)
|
if (values == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
|
|||||||
const oldValue = get(this.value)
|
const oldValue = get(this.value)
|
||||||
if (this.properties.values.indexOf(oldValue) === -1) {
|
if (this.properties.values.indexOf(oldValue) === -1) {
|
||||||
changed = true;
|
changed = true;
|
||||||
this.value.set(this.properties.values[0])
|
this.value.set(defaultValue || this.properties.values[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lightUp && get(this.firstLoad) && changed)
|
if (lightUp && get(this.firstLoad) && changed)
|
||||||
@@ -129,7 +129,7 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
|
|||||||
thisProps.values = Array.from(otherProps.values);
|
thisProps.values = Array.from(otherProps.values);
|
||||||
const value = get(this.value)
|
const value = get(this.value)
|
||||||
if (thisProps.values.indexOf(value) === -1)
|
if (thisProps.values.indexOf(value) === -1)
|
||||||
this.setValue(thisProps.values[0])
|
this.setValue(otherProps.defaultValue || thisProps.values[0])
|
||||||
|
|
||||||
console.warn("PASSED")
|
console.warn("PASSED")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user