mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
fix(data-table): table header keys should be reactive (#1346)
Fixes #1345 Co-authored-by: Jorge Vergara <jbvergara@bethel.jw.org>
This commit is contained in:
parent
b21718ccfd
commit
0f060ea035
1 changed files with 2 additions and 7 deletions
|
@ -144,13 +144,8 @@
|
||||||
};
|
};
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
const batchSelectedIds = writable(false);
|
const batchSelectedIds = writable(false);
|
||||||
const headerItems = writable([]);
|
|
||||||
const tableRows = writable(rows);
|
const tableRows = writable(rows);
|
||||||
const thKeys = derived(headerItems, () =>
|
$: thKeys = headers.reduce((a, c) => ({ ...a, [c.key]: c.key }), {});
|
||||||
headers
|
|
||||||
.map(({ key }) => ({ key, id: key }))
|
|
||||||
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
|
|
||||||
);
|
|
||||||
const resolvePath = (object, path) => {
|
const resolvePath = (object, path) => {
|
||||||
if (path in object) return object[path];
|
if (path in object) return object[path];
|
||||||
return path
|
return path
|
||||||
|
@ -356,7 +351,7 @@
|
||||||
sortKey === header.key ? sortDirection : 'none';
|
sortKey === header.key ? sortDirection : 'none';
|
||||||
sortDirection = sortDirectionMap[currentSortDirection];
|
sortDirection = sortDirectionMap[currentSortDirection];
|
||||||
sortKey =
|
sortKey =
|
||||||
sortDirection === 'none' ? null : $thKeys[header.key];
|
sortDirection === 'none' ? null : thKeys[header.key];
|
||||||
dispatch('click:header', { header, sortDirection });
|
dispatch('click:header', { header, sortDirection });
|
||||||
}
|
}
|
||||||
}}"
|
}}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue