@@ -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