Skip to content

Commit e91d858

Browse files
committed
fix: improve title field inference logic in ObjectKanban and update vitest config for plugin-kanban
1 parent e3f1797 commit e91d858

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

apps/console/src/__tests__/KanbanTodoDisplay.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ describe('ObjectKanban Todo Example Display', () => {
6060
);
6161

6262
// Wait for data to appear
63+
// If logic is wrong, it will look for 'name', find undefined, show 'Untitled'.
64+
// This assertion checks 'Task A' is visible.
6365
await waitFor(() => expect(screen.getByText('Task A')).toBeInTheDocument());
6466

6567
// Verify Column Headers (H3 in real component)

packages/plugin-kanban/src/ObjectKanban.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,26 +104,26 @@ export const ObjectKanban: React.FC<ObjectKanbanProps> = ({
104104

105105
// Fallback: Try to infer from object definition
106106
if (!titleField && objectDef) {
107-
// 1. Check for standard NAME_FIELD_KEY
108-
if (objectDef.NAME_FIELD_KEY) {
109-
titleField = objectDef.NAME_FIELD_KEY;
110-
}
111-
// 2. Check for titleFormat like "{subject}"
112-
else if (objectDef.titleFormat) {
107+
// 1. Check for titleFormat like "{subject}" first (Higher priority for Cards)
108+
if (objectDef.titleFormat) {
113109
const match = /\{(.+?)\}/.exec(objectDef.titleFormat);
114110
if (match) titleField = match[1];
115111
}
112+
// 2. Check for standard NAME_FIELD_KEY
113+
if (!titleField && objectDef.NAME_FIELD_KEY) {
114+
titleField = objectDef.NAME_FIELD_KEY;
115+
}
116116
}
117117

118118
// Default to 'name'
119-
titleField = titleField || 'name';
119+
const finalTitleField = titleField || 'name';
120120

121121
return rawData.map(item => ({
122122
...item,
123123
// Ensure id exists
124124
id: item.id || item._id,
125125
// Map title
126-
title: item[titleField] || item.title || 'Untitled',
126+
title: item[finalTitleField] || item.title || 'Untitled',
127127
}));
128128
}, [rawData, schema, objectDef]);
129129

vitest.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default defineConfig({
4848
'@object-ui/fields': path.resolve(__dirname, './packages/fields/src'),
4949
'@object-ui/plugin-dashboard': path.resolve(__dirname, './packages/plugin-dashboard/src'),
5050
'@object-ui/plugin-grid': path.resolve(__dirname, './packages/plugin-grid/src'),
51+
'@object-ui/plugin-kanban': path.resolve(__dirname, './packages/plugin-kanban/src'),
5152
'@': path.resolve(__dirname, './packages/components/src'),
5253
'@object-ui/ui': path.resolve(__dirname, './packages/ui/src'),
5354
},

0 commit comments

Comments
 (0)