Skip to content

Commit

Permalink
Merge pull request #192 from finos/merge-depth
Browse files Browse the repository at this point in the history
Fix autosize to use last merged column header
  • Loading branch information
texodus authored Aug 29, 2023
2 parents 317d45d + 31aac9a commit 743f0d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/js/thead.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class RegularHeaderViewModel extends ViewModel {
const header_levels = parts?.length; //config.column_pivots.length + 1;
if (header_levels === 0) return;
let th, metadata, column_name;
let output = undefined;
column_header_merge_depth = typeof column_header_merge_depth === "undefined" ? header_levels - 1 : column_header_merge_depth;
for (let d = 0; d < header_levels; d++) {
column_name = parts[d] ? parts[d] : "";
Expand All @@ -113,12 +114,17 @@ export class RegularHeaderViewModel extends ViewModel {
// header has the same metadata coordinates of its rightmost
// column.
metadata = this._draw_th(alias || parts, column_name, th, x, size_key);
if (typeof output === "undefined") {
output = { th, metadata };
}

for (const [group_meta] of this._group_header_cache) {
group_meta.size_key = metadata.size_key;
}
th.removeAttribute("colspan");
}

this._get_row(d).tr.classList.toggle("rt-autosize", d === column_header_merge_depth);
th.classList.toggle("rt-group-corner", x === undefined);
if (metadata) {
metadata.x = typeof x === "undefined" ? x : Math.floor(x);
Expand All @@ -132,7 +138,8 @@ export class RegularHeaderViewModel extends ViewModel {
}

this._clean_rows(this._offset_cache.length);
return { th, metadata };
output = output || { th, metadata };
return output;
}

clean() {
Expand Down
2 changes: 1 addition & 1 deletion src/less/material.less
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ regular-table {
}

// Header groups should overflow and not contribute to auto-sizing.
thead tr:not(:last-child) th {
thead tr:not(.rt-autosize) th {
overflow: hidden;
max-width: 0px;
}
Expand Down

0 comments on commit 743f0d7

Please sign in to comment.