fix(data-table): rows should be reactive (#1255)

This commit is contained in:
Nicolas Peugnet 2022-04-19 02:50:19 +02:00 committed by GitHub
commit 43e2986434
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,16 +195,14 @@
$: if (radio || batchSelection) selectable = true; $: if (radio || batchSelection) selectable = true;
$: tableSortable.set(sortable); $: tableSortable.set(sortable);
$: headerKeys = headers.map(({ key }) => key); $: headerKeys = headers.map(({ key }) => key);
$: tableRows.set( $: $tableRows = rows.map((row) => ({
rows.map((row) => ({
...row, ...row,
cells: headerKeys.map((key, index) => ({ cells: headerKeys.map((key, index) => ({
key, key,
value: resolvePath(row, key), value: resolvePath(row, key),
display: headers[index].display, display: headers[index].display,
})), })),
})) }));
);
$: sortedRows = [...$tableRows]; $: sortedRows = [...$tableRows];
$: ascending = $sortHeader.sortDirection === "ascending"; $: ascending = $sortHeader.sortDirection === "ascending";
$: sortKey = $sortHeader.key; $: sortKey = $sortHeader.key;