hotfix(data-table): column sort direction order should be independent (#1342)

Fixes #1341
This commit is contained in:
metonym 2022-06-09 11:14:14 -07:00 committed by GitHub
commit e56ee83dc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -344,15 +344,17 @@
id="{header.key}" id="{header.key}"
style="{formatHeaderWidth(header)}" style="{formatHeaderWidth(header)}"
sortable="{sortable && header.sort !== false}" sortable="{sortable && header.sort !== false}"
sortDirection="{sortDirection}" sortDirection="{sortKey === header.key ? sortDirection : 'none'}"
active="{sortKey !== null && sortKey === header.key}" active="{sortKey === header.key}"
on:click="{() => { on:click="{() => {
dispatch('click', { header }); dispatch('click', { header });
if (header.sort === false) { if (header.sort === false) {
dispatch('click:header', { header }); dispatch('click:header', { header });
} else { } else {
sortDirection = sortDirectionMap[sortDirection]; let currentSortDirection =
sortKey === header.key ? sortDirection : 'none';
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 });