mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +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 batchSelectedIds = writable(false);
|
||||
const headerItems = writable([]);
|
||||
const tableRows = writable(rows);
|
||||
const thKeys = derived(headerItems, () =>
|
||||
headers
|
||||
.map(({ key }) => ({ key, id: key }))
|
||||
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
|
||||
);
|
||||
$: thKeys = headers.reduce((a, c) => ({ ...a, [c.key]: c.key }), {});
|
||||
const resolvePath = (object, path) => {
|
||||
if (path in object) return object[path];
|
||||
return path
|
||||
|
@ -356,7 +351,7 @@
|
|||
sortKey === header.key ? sortDirection : 'none';
|
||||
sortDirection = sortDirectionMap[currentSortDirection];
|
||||
sortKey =
|
||||
sortDirection === 'none' ? null : $thKeys[header.key];
|
||||
sortDirection === 'none' ? null : thKeys[header.key];
|
||||
dispatch('click:header', { header, sortDirection });
|
||||
}
|
||||
}}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue