Skip to content

Commit b2355c7

Browse files
committed
Fix input order
Sorry Alex, I've failed you
1 parent 203a878 commit b2355c7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/graph/widgets/dynamicWidgets.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ function dynamicComboWidget(
5757

5858
const insertionPoint = node.widgets.findIndex((w) => w === widget) + 1
5959
const startingLength = node.widgets.length
60-
const inputInsertionPoint =
60+
const initialInputIndex =
6161
node.inputs.findIndex((i) => i.name === widget.name) + 1
62-
const startingInputLength = node.inputs.length
62+
let startingInputLength = node.inputs.length
6363
if (insertionPoint === 0)
6464
throw new Error("Dynamic widget doesn't exist on node")
6565
const inputTypes: [Record<string, InputSpec> | undefined, boolean][] = [
@@ -92,8 +92,11 @@ function dynamicComboWidget(
9292
for (const input of Object.values(inputsToRemove)) {
9393
const inputIndex = node.inputs.findIndex((inp) => inp === input)
9494
if (inputIndex === -1) continue
95+
if (inputIndex < initialInputIndex) startingInputLength--
9596
node.removeInput(inputIndex)
9697
}
98+
const inputInsertionPoint =
99+
node.inputs.findIndex((i) => i.name === widget.name) + 1
97100
const addedWidgets = node.widgets.splice(startingLength)
98101
node.widgets.splice(insertionPoint, 0, ...addedWidgets)
99102
if (inputInsertionPoint === 0) {

0 commit comments

Comments
 (0)