@@ -291,6 +291,13 @@ export const ListView: React.FC<ListViewProps> = ({
291291 viewType : propSchema . viewType || 'grid'
292292 } ) , [ propSchema ] ) ;
293293
294+ // Convenience: resolve field label with schema.objectName pre-bound
295+ const tFieldLabel = React . useCallback (
296+ ( fieldName : string , fallback : string ) =>
297+ schema . objectName ? resolveFieldLabel ( schema . objectName , fieldName , fallback ) : fallback ,
298+ [ schema . objectName , resolveFieldLabel ] ,
299+ ) ;
300+
294301 // Resolve toolbar visibility flags: userActions overrides showX flags
295302 const toolbarFlags = React . useMemo ( ( ) => {
296303 const ua = schema . userActions ;
@@ -433,7 +440,7 @@ export const ListView: React.FC<ListViewProps> = ({
433440 if ( FILTERABLE_FIELD_TYPES . has ( field . type ) || ( field . options && ! field . type ) ) {
434441 derivedFields . push ( {
435442 field : key ,
436- label : schema . objectName ? resolveFieldLabel ( schema . objectName , key , field . label || key ) : ( field . label || key ) ,
443+ label : tFieldLabel ( key , field . label || key ) ,
437444 type : field . type === 'boolean' ? 'boolean' : field . type === 'multi-select' ? 'multi-select' : 'select' ,
438445 } ) ;
439446 }
@@ -897,17 +904,18 @@ export const ListView: React.FC<ListViewProps> = ({
897904 // Fallback to schema fields if objectDef not loaded yet
898905 fields = ( schema . fields || [ ] ) . map ( ( f : any ) => {
899906 if ( typeof f === 'string' ) return { value : f , label : f , type : 'text' } ;
907+ const fieldName = f . name || f . fieldName ;
900908 return {
901- value : f . name || f . fieldName ,
902- label : schema . objectName ? resolveFieldLabel ( schema . objectName , f . name || f . fieldName , f . label || f . name ) : ( f . label || f . name ) ,
909+ value : fieldName ,
910+ label : tFieldLabel ( fieldName , f . label || f . name ) ,
903911 type : f . type || 'text' ,
904912 options : f . options
905913 } ;
906914 } ) ;
907915 } else {
908916 fields = Object . entries ( objectDef . fields ) . map ( ( [ key , field ] : [ string , any ] ) => ( {
909917 value : key ,
910- label : schema . objectName ? resolveFieldLabel ( schema . objectName , key , field . label || key ) : ( field . label || key ) ,
918+ label : tFieldLabel ( key , field . label || key ) ,
911919 type : field . type || 'text' ,
912920 options : field . options
913921 } ) ) ;
@@ -994,15 +1002,13 @@ export const ListView: React.FC<ListViewProps> = ({
9941002 const allFields = React . useMemo ( ( ) => {
9951003 return ( schema . fields || [ ] ) . map ( ( f : any ) => {
9961004 if ( typeof f === 'string' ) {
997- const label = schema . objectName ? resolveFieldLabel ( schema . objectName , f , f ) : f ;
998- return { name : f , label } ;
1005+ return { name : f , label : tFieldLabel ( f , f ) } ;
9991006 }
10001007 const name = f . name || f . fieldName || f . field ;
10011008 const rawLabel = f . label || f . name || f . field ;
1002- const label = schema . objectName ? resolveFieldLabel ( schema . objectName , name , rawLabel ) : rawLabel ;
1003- return { name, label } ;
1009+ return { name, label : tFieldLabel ( name , rawLabel ) } ;
10041010 } ) ;
1005- } , [ schema . fields , schema . objectName , resolveFieldLabel ] ) ;
1011+ } , [ schema . fields , tFieldLabel ] ) ;
10061012
10071013 return (
10081014 < div
0 commit comments