@@ -7,10 +7,12 @@ import { LuPanelTopClose, LuPanelTopOpen } from 'react-icons/lu'
77import IconButton from '@/components/Chakra/IconButton.tsx'
88import { CopyButton , MoveDownButton , MoveUpButton , RemoveButton } from '@/components/rjsf/__internals/IconButton.tsx'
99import { useFormControlStore } from '@/components/rjsf/Form/useFormControlStore.ts'
10+ import { formatItemName } from '@/components/rjsf/utils/array-items.utils.ts'
1011
1112// TODO[NVL] Need a better handling of the custom UISchema property, for the Adapter SDK
1213interface ArrayFieldItemCollapsableUISchema {
1314 titleKey : string
15+ name : string
1416}
1517
1618// TODO[NVL] This is driven by subscription handling; use uiSchema to allow configuration for individual array property
@@ -49,9 +51,9 @@ export const ArrayFieldItemTemplate: FC<ArrayFieldTemplateItemType> = (props) =>
4951 const childrenFormData = collapsableItems ?. titleKey
5052 ? children . props . formData [ collapsableItems ?. titleKey ]
5153 : undefined
52- if ( childrenFormData ) return ` ${ children . props . name } - ${ childrenFormData } `
53- return children . props . name
54- } , [ children . props . formData , children . props . name , collapsableItems ?. titleKey ] )
54+
55+ return formatItemName ( collapsableItems ?. name , children . props . index , childrenFormData )
56+ } , [ children . props . formData , children . props . index , collapsableItems ?. name , collapsableItems ?. titleKey ] )
5557
5658 useEffect ( ( ) => {
5759 if ( props . children . props . idSchema . $id === expandItems . join ( '_' ) ) onOpen ( )
@@ -82,6 +84,12 @@ export const ArrayFieldItemTemplate: FC<ArrayFieldTemplateItemType> = (props) =>
8284 }
8385 const { hidden, ...rest } = getDisclosureProps ( )
8486
87+ // This is to override the hardcoded rendering of the item's indexed names
88+ const childrenWithCustomTitle = {
89+ ...children ,
90+ props : { ...children . props , title : formatItemName ( collapsableItems ?. name , children . props . index ) } ,
91+ }
92+
8593 return (
8694 < HStack flexDirection = "row-reverse" alignItems = "flex-start" py = { 1 } role = "listitem" >
8795 { hasToolbar && (
@@ -136,7 +144,7 @@ export const ArrayFieldItemTemplate: FC<ArrayFieldTemplateItemType> = (props) =>
136144 ) }
137145
138146 < Box w = "100%" { ...rest } >
139- { ! collapsableItems || isOpen ? children : renderCollapsed ( ) }
147+ { ! collapsableItems || isOpen ? childrenWithCustomTitle : renderCollapsed ( ) }
140148 </ Box >
141149 </ HStack >
142150 )
0 commit comments