mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
Support keeping value across dynamic combo options
This commit is contained in:
@@ -95,7 +95,9 @@ function dynamicComboWidget(
|
||||
const newSpec = value ? options[value] : undefined
|
||||
|
||||
const removedInputs = remove(node.inputs, isInGroup)
|
||||
for (const widget of remove(node.widgets, isInGroup)) widget.onRemove?.()
|
||||
|
||||
const removedWidgets = remove(node.widgets, isInGroup)
|
||||
for (const widget of removedWidgets) widget.onRemove?.()
|
||||
|
||||
if (!newSpec) return
|
||||
|
||||
@@ -174,6 +176,18 @@ function dynamicComboWidget(
|
||||
)
|
||||
}
|
||||
}
|
||||
for (const widget of removedWidgets) {
|
||||
const newMatchingWidget = addedWidgets.find((w) => w.name === widget.name)
|
||||
if (!newMatchingWidget || newMatchingWidget.type !== widget.type) continue
|
||||
|
||||
const nameSegment = widget.name.slice(widget.name.lastIndexOf('.') + 1)
|
||||
const spec =
|
||||
newSpec.required?.[nameSegment] ?? newSpec.optional?.[nameSegment]
|
||||
if (spec?.[1] && 'default' in spec?.[1]) continue
|
||||
|
||||
newMatchingWidget.value = widget.value
|
||||
newMatchingWidget.callback?.(widget.value)
|
||||
}
|
||||
|
||||
node.size[1] = node.computeSize([...node.size])[1]
|
||||
if (!node.graph) return
|
||||
|
||||
@@ -24,6 +24,10 @@ function onValueChange(this: INumericWidget, v: number) {
|
||||
// Round to nearest step, accounting for offset
|
||||
this.value = Math.round((v - offset) / step) * step + offset
|
||||
}
|
||||
if (this.options.min !== undefined && this.value < this.options.min)
|
||||
this.value = this.options.min
|
||||
if (this.options.max !== undefined && this.value > this.options.max)
|
||||
this.value = this.options.max
|
||||
}
|
||||
|
||||
export const _for_testing = {
|
||||
|
||||
Reference in New Issue
Block a user