From d7f4bf03e4e51091f32fd0edabe12f964178819b Mon Sep 17 00:00:00 2001 From: Miguel Vieira Date: Thu, 14 Nov 2024 15:37:12 +0000 Subject: [PATCH] fix(indexcard): check if column accessor is a function The formatValue function in IndexCard.svelte wasn't properly handling column accessors that were functions, causing undefined values for the date column. Updated the function to properly evaluate function accessors before passing the value to cell formatters. --- src/lib/components/table/IndexCard.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/components/table/IndexCard.svelte b/src/lib/components/table/IndexCard.svelte index 82d153a6d..a42f14857 100644 --- a/src/lib/components/table/IndexCard.svelte +++ b/src/lib/components/table/IndexCard.svelte @@ -8,10 +8,14 @@ export let url: string; function formatValue(item: Record, column: Column) { + const value = + typeof column.accessor === 'function' ? column.accessor(item) : item[column.accessor]; + if (column.cell) { - return column.cell({ value: item[column.accessor] }); + return column.cell({ value }); } - return item[column.accessor] ?? 'N/A'; + + return value ?? 'N/A'; }