From 7aea651df5d73e1760db6ef3a8aee9e45017e210 Mon Sep 17 00:00:00 2001 From: Vadym Samoilenko Date: Mon, 23 Mar 2026 17:28:24 +0000 Subject: [PATCH] Fix Category/Media dropdowns: use cells() callback for dynamic sources Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/pages/SheetPage.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/SheetPage.tsx b/frontend/src/pages/SheetPage.tsx index 9d9e3a7..8fa7208 100644 --- a/frontend/src/pages/SheetPage.tsx +++ b/frontend/src/pages/SheetPage.tsx @@ -53,8 +53,6 @@ export default function SheetPage() { } }, [sheetId]) - const categoryNames = categories.map(c => c.name) - const columns: Handsontable.ColumnSettings[] = [ { data: 'Number', title: '#', width: 70, readOnly: true }, { data: 'Title', title: 'Title', width: 200 }, @@ -64,15 +62,11 @@ export default function SheetPage() { }, { data: 'Category', title: 'Category', width: 180, - type: 'autocomplete', source: categoryNames, strict: false, filter: true, + type: 'dropdown', strict: false, }, { data: 'Media', title: 'Media', width: 180, - type: 'autocomplete', strict: false, filter: true, - source(_query: string, process: (items: string[]) => void) { - // Dynamic source — resolved in cells() callback below - process([]) - }, + type: 'dropdown', strict: false, }, { data: 'Sub-media', title: 'Sub-media', width: 120 }, { data: 'Format', title: 'Format', width: 100 }, @@ -83,8 +77,12 @@ export default function SheetPage() { ] const cells = useCallback((row: number, col: number): Handsontable.CellMeta => { + if (col === 3) { + // Category — source from admin dropdowns + return { source: categories.map(c => c.name) } + } if (col === 4) { - // Media column — filter based on current row's Category + // Media — filter based on current row's Category const hot = hotRef.current?.hotInstance const category = hot?.getDataAtRowProp(row, 'Category') as string | undefined const cat = categories.find(c => c.name === category)