mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(data-table): headers
should be reactive (#1075)
If `headers` is dynamically updated, clicking a sortable table header will sort the incorrect column. Instead of randomly generating an id and keeping track of it through context, we can simply use the required key in `headers` as the id.
This commit is contained in:
parent
cbecfd41e2
commit
a5f5550aa0
2 changed files with 2 additions and 7 deletions
|
@ -136,7 +136,7 @@
|
|||
const headerItems = writable([]);
|
||||
const thKeys = derived(headerItems, () =>
|
||||
headers
|
||||
.map(({ key }, i) => ({ key, id: $headerItems[i] }))
|
||||
.map(({ key }, i) => ({ key, id: key }))
|
||||
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
|
||||
);
|
||||
const resolvePath = (object, path) =>
|
||||
|
@ -154,9 +154,6 @@
|
|||
selectedRowIds = [];
|
||||
if (refSelectAll) refSelectAll.checked = false;
|
||||
},
|
||||
add: (id) => {
|
||||
headerItems.update((_) => [..._, id]);
|
||||
},
|
||||
});
|
||||
|
||||
let expanded = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue