Skip to content

Commit fbfe63f

Browse files
authored
Merge pull request #259 from finos/row-header-column-override-fix
Fix row header column resize
2 parents 5ede30b + b66824a commit fbfe63f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/ts/table.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -449,18 +449,20 @@ export class RegularTableViewModel extends RegularTableViewModelBase {
449449
// CSS :nth-child is 1-indexed
450450
const columnIndex = row_headers_size_key + 1; // - Math.floor(viewport.start_col);
451451

452+
// Work backwards to handle colspan/rowspan missing elements in
453+
// `row_headers`.
452454
cssRules.push(
453-
`thead tr.rt-autosize th:nth-child(${columnIndex}),`,
454-
`tbody td.rt-cell-clip:nth-child(${columnIndex})`,
455+
`thead tr.rt-autosize th:nth-of-type(${columnIndex}),`,
456+
`tbody th.rt-cell-clip:nth-last-of-type(${row_headers_length - row_headers_size_key})`,
455457
`{min-width:${override_width}px;max-width:${override_width}px;}`,
456458
);
457459
} else if (auto_width !== undefined) {
458460
// Auto width applies when no override
459461
const columnIndex = row_headers_size_key + 1; // - Math.floor(viewport.start_col);
460462
cssRules.push(
461-
`thead tr.rt-autosize th:nth-child(${columnIndex}),`,
462-
`tbody td.rt-cell-clip:nth-child(${columnIndex})`,
463-
`{min-width:${auto_width}px;max-width:none;}`,
463+
`thead tr.rt-autosize th:nth-of-type(${columnIndex}),`,
464+
`tbody th.rt-cell-clip:nth-last-of-type(${row_headers_length - row_headers_size_key})`,
465+
`{min-width:${auto_width}px;}`,
464466
);
465467
}
466468
}
@@ -486,17 +488,17 @@ export class RegularTableViewModel extends RegularTableViewModelBase {
486488
// CSS :nth-child is 1-indexed
487489
const columnIndex = size_key + 1; // Math.floor(viewport.start_col);
488490
cssRules.push(
489-
`thead tr.rt-autosize th:nth-child(${columnIndex}),`,
490-
`tbody td.rt-cell-clip:nth-child(${columnIndex})`,
491+
`thead tr.rt-autosize th:nth-of-type(${columnIndex}),`,
492+
`tbody td.rt-cell-clip:nth-of-type(${columnIndex - row_headers_size_key})`,
491493
`{min-width:${override_width}px;max-width:${override_width}px;}`,
492494
);
493495
} else if (auto_width !== undefined) {
494496
// Auto width applies when no override
495497
const columnIndex = size_key + 1; // Math.floor(viewport.start_col);
496498
cssRules.push(
497-
`thead tr.rt-autosize th:nth-child(${columnIndex}),`,
498-
`tbody td.rt-cell-clip:nth-child(${columnIndex})`,
499-
`{min-width:${auto_width}px;max-width:none;}`,
499+
`thead tr.rt-autosize th:nth-of-type(${columnIndex}),`,
500+
`tbody td.rt-cell-clip:nth-of-type(${columnIndex - row_headers_size_key})`,
501+
`{min-width:${auto_width}px;}`,
500502
);
501503
}
502504
}

0 commit comments

Comments
 (0)