Skip to content

Commit

Permalink
Merge branch 'develop' into 4314-aria-current-handling-via-observer-e…
Browse files Browse the repository at this point in the history
…ntkoppeln
  • Loading branch information
sdvg authored Nov 16, 2023
2 parents 53c765f + 5ace636 commit c6a9c18
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions packages/components/src/components/table/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,20 @@ export class KolTable implements API {
watchValidator(this, '_headers', (value): boolean => typeof value === 'object' && value !== null, new Set(['KoliBriTableHeaders']), value, {
hooks: {
beforePatch: (nextValue: unknown) => {
const headers: KoliBriTableHeaders = nextValue as KoliBriTableHeaders;
headers.horizontal?.forEach((header) => {
header.forEach((cell) => {
if (typeof cell.sort === 'function' && typeof cell.sortDirection === 'string') {
this.setSortDirection(cell.sort, cell.sortDirection);
}
});
});
headers.vertical?.forEach((header) => {
header.forEach((cell) => {
if (typeof cell.sort === 'function' && typeof cell.sortDirection === 'string') {
this.setSortDirection(cell.sort, cell.sortDirection);
const applySort = (headers: KoliBriTableHeaderCell[]) => {
headers.forEach((cell, i) => {
const sortDirection = cell.sortDirection;
if (typeof cell.sort === 'function' && (sortDirection === 'ASC' || sortDirection === 'DESC')) {
this.setSortDirection(cell.sort, sortDirection);
setTimeout(() => this.updateSortedData({ key: cell.key || `cell-${i}`, label: cell.label, sortDirection }));
}
});
});
};

const headers: KoliBriTableHeaders = nextValue as KoliBriTableHeaders;
headers.horizontal?.forEach(applySort);
headers.vertical?.forEach(applySort);

if (headers.horizontal && headers.vertical && headers.horizontal?.length > 0 && headers.vertical?.length > 0) {
this.disableSort = true;
devHint(
Expand Down

0 comments on commit c6a9c18

Please sign in to comment.