Skip to content

Commit a3a3cc3

Browse files
Copilothotlong
andcommitted
fix: address code review - add a11y labels to summary badges, check objectDef.primaryField, warn on missing fields
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent c167551 commit a3a3cc3

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/console/src/components/RecordDetailView.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
198198
);
199199
}
200200

201-
// Auto-detect primary field (name or title)
202-
const primaryField = Object.keys(objectDef.fields || {}).find(
203-
(key) => key === 'name' || key === 'title'
204-
);
201+
// Auto-detect primary field: prefer objectDef metadata, then 'name' or 'title' heuristic
202+
const primaryField = objectDef.primaryField
203+
|| Object.keys(objectDef.fields || {}).find(
204+
(key) => key === 'name' || key === 'title'
205+
);
205206

206207
// Build sections: prefer form sections from objectDef, fallback to flat field list
207208
const formSections = objectDef.views?.form?.sections;
@@ -213,7 +214,10 @@ export function RecordDetailView({ dataSource, objects, onEdit }: RecordDetailVi
213214
fields: (sec.fields || []).map((f: any) => {
214215
const fieldName = typeof f === 'string' ? f : f.name;
215216
const fieldDef = objectDef.fields[fieldName];
216-
if (!fieldDef) return { name: fieldName, label: fieldName };
217+
if (!fieldDef) {
218+
console.warn(`[RecordDetailView] Field "${fieldName}" not found in ${objectDef.name} definition`);
219+
return { name: fieldName, label: fieldName };
220+
}
217221
return {
218222
name: fieldName,
219223
label: fieldDef.label || fieldName,

packages/plugin-detail/src/DetailView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export const DetailView: React.FC<DetailViewProps> = ({
257257
const val = data?.[fieldName];
258258
if (val === null || val === undefined || val === '') return null;
259259
return (
260-
<Badge key={fieldName} variant="secondary" className="text-xs">
260+
<Badge key={fieldName} variant="secondary" className="text-xs" aria-label={`${fieldName}: ${val}`}>
261261
{String(val)}
262262
</Badge>
263263
);

0 commit comments

Comments
 (0)