Skip to content

Commit 0caea33

Browse files
os-zhuangclaude
andauthored
fix(grid): list column header falls back to field label, not prettified name (#1991)
A bare { field } column (no explicit label) rendered its header from the prettified machine name even when the field had a localized label, so non-English apps showed English column headers. ObjectGrid now resolves header = column.label -> schema field label -> prettified name, matching the other header sites (lines ~1027/1104). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e301475 commit 0caea33

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-grid': patch
3+
---
4+
5+
fix(grid): list column headers fall back to the field's label, not the prettified machine name
6+
7+
A view column declared as a bare `{ field: 'request_title' }` (no explicit `label`) rendered
8+
its header from the prettified machine name ("Request title") even when the field had a
9+
localized label ("申请标题"). On a non-English app that surfaced English column headers despite
10+
fully-localized field labels. ObjectGrid now resolves the header as
11+
`column.label → schema field label → prettified name`, matching the other header-resolution
12+
sites in the same file. Found dogfooding AI-built Chinese apps.

packages/plugin-grid/src/ObjectGrid.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,13 @@ export const ObjectGrid: React.FC<ObjectGridProps> = ({
860860
return (cols as ListColumn[])
861861
.filter((col) => col?.field && typeof col.field === 'string' && !col.hidden)
862862
.map((col, colIndex) => {
863-
const rawHeader = resolveColumnLabel(col.label) || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
863+
// Fall back to the SCHEMA FIELD's label before prettifying the machine
864+
// name — otherwise a column declared as bare { field } shows an English
865+
// name-derived header (e.g. "Request title") even when the field has a
866+
// localized label (e.g. "申请标题") on a non-English app.
867+
const rawHeader = resolveColumnLabel(col.label)
868+
|| resolveColumnLabel(objectSchema?.fields?.[col.field]?.label)
869+
|| col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
864870
const header = schema.objectName ? resolveFieldLabel(schema.objectName, col.field, rawHeader) : rawHeader;
865871

866872
// Build custom cell renderer based on column configuration

0 commit comments

Comments
 (0)