1- import { memo , useEffect , useRef , useState } from 'react'
1+ import { memo , useCallback , useEffect , useRef , useState } from 'react'
22import { useUpdateNodeInternals } from 'reactflow'
33
44import { Avatar , Box , ButtonBase , Dialog , DialogContent , Stack , TextField , Typography } from '@mui/material'
@@ -30,6 +30,22 @@ function EditNodeDialogComponent({ show, dialogProps, onCancel }: EditNodeDialog
3030 const [ data , setData ] = useState < NodeData | null > ( null )
3131 const [ isEditingNodeName , setEditingNodeName ] = useState ( false )
3232 const [ nodeName , setNodeName ] = useState ( '' )
33+ const [ arrayItemParameters , setArrayItemParameters ] = useState < Record < string , InputParam [ ] [ ] > > ( { } )
34+
35+ // Evaluate field visibility for each item in every array-type param.
36+ const computeArrayItemParameters = useCallback (
37+ ( params : InputParam [ ] , inputValues : Record < string , unknown > ) : Record < string , InputParam [ ] [ ] > => {
38+ const result : Record < string , InputParam [ ] [ ] > = { }
39+ for ( const param of params ) {
40+ if ( param . type === 'array' && param . array ) {
41+ const items = ( inputValues [ param . name ] as Record < string , unknown > [ ] ) || [ ]
42+ result [ param . name ] = items . map ( ( _ , index ) => evaluateFieldVisibility ( param . array ! , inputValues , index ) )
43+ }
44+ }
45+ return result
46+ } ,
47+ [ ]
48+ )
3349
3450 const onNodeLabelChange = ( ) => {
3551 if ( ! data || ! nodeNameRef . current ) return
@@ -50,6 +66,7 @@ function EditNodeDialogComponent({ show, dialogProps, onCancel }: EditNodeDialog
5066
5167 const updatedParams = evaluateFieldVisibility ( inputParams , updatedInputValues )
5268 setInputParams ( updatedParams )
69+ setArrayItemParameters ( computeArrayItemParameters ( inputParams , updatedInputValues ) )
5370 // Keep full inputValues in state — hidden field values are preserved so they
5471 // can be restored when visibility conditions change (e.g. toggling provider back).
5572 // Stripping should only happen on save/export, not on every keystroke.
@@ -62,12 +79,13 @@ function EditNodeDialogComponent({ show, dialogProps, onCancel }: EditNodeDialog
6279 const initialValues = dialogProps . data ?. inputValues || { }
6380 const evaluatedParams = evaluateFieldVisibility ( dialogProps . inputParams , initialValues )
6481 setInputParams ( evaluatedParams )
82+ setArrayItemParameters ( computeArrayItemParameters ( dialogProps . inputParams , initialValues ) )
6583 }
6684 if ( dialogProps . data ) {
6785 setData ( dialogProps . data )
6886 if ( dialogProps . data . label ) setNodeName ( dialogProps . data . label )
6987 }
70- } , [ dialogProps ] )
88+ } , [ dialogProps , computeArrayItemParameters ] )
7189
7290 if ( ! show ) return null
7391
@@ -233,6 +251,7 @@ function EditNodeDialogComponent({ show, dialogProps, onCancel }: EditNodeDialog
233251 data = { data }
234252 isAdditionalParams = { true }
235253 onDataChange = { onCustomDataChange }
254+ itemParameters = { inputParam . type === 'array' ? arrayItemParameters [ inputParam . name ] : undefined }
236255 />
237256 )
238257 } ) }
0 commit comments