Skip to content

Commit b9cd1bd

Browse files
AustinMrozDrJKL
authored andcommitted
Fix key renaming
1 parent d07e4ab commit b9cd1bd

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/extensions/core/dynamicCombo.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ function COMFY_DYNAMICCOMBO_V3(
1919
const options = Object.fromEntries(
2020
inputData[1].options.map(({ key, inputs }) => [key, inputs])
2121
)
22-
for (const option of Object.values(options))
23-
for (const inputType of [option.required, option.optional])
24-
for (const key in inputType ?? {}) {
25-
inputType![key][1] ??= {}
26-
inputType![key][1].label = key
27-
}
28-
2922
const subSpec: ComboInputSpec = [Object.keys(options), {}]
3023
const { widget, minWidth, minHeight } = app.widgets['COMBO'](
3124
node,
@@ -54,6 +47,7 @@ function COMFY_DYNAMICCOMBO_V3(
5447

5548
const insertionPoint = node.widgets.findIndex((w) => w === widget) + 1
5649
const startingLength = node.widgets.length
50+
const startingInputLength = node.inputs.length
5751
if (insertionPoint === 0)
5852
throw new Error("Dynamic widget doesn't exist on node")
5953
//FIXME: inputs MUST be well ordered
@@ -63,19 +57,24 @@ function COMFY_DYNAMICCOMBO_V3(
6357
[newSpec.optional, true]
6458
]
6559
for (const [inputType, isOptional] of inputTypes)
66-
for (const key in inputType ?? {}) {
67-
const name = `${widget.name}.${key}`
60+
for (const name in inputType ?? {}) {
6861
//@ts-expect-error temporary duck violence
6962
node._addInput(
70-
transformInputSpecV1ToV2(inputType![key], {
63+
transformInputSpecV1ToV2(inputType![name], {
7164
name,
7265
isOptional
7366
})
7467
)
75-
currentDynamicNames.push(name)
68+
currentDynamicNames.push(`${widget.name}.${name}`)
7669
}
7770

7871
const addedWidgets = node.widgets.splice(startingLength)
72+
for (const addedWidget of addedWidgets) {
73+
addedWidget.name = `${widget.name}.${addedWidget.name}`
74+
}
75+
for (const input of node.inputs.slice(startingInputLength)) {
76+
input.name = `${widget.name}.${input.name}`
77+
}
7978
node.widgets.splice(insertionPoint, 0, ...addedWidgets)
8079
node.computeSize(node.size)
8180
}

0 commit comments

Comments
 (0)