Skip to content

Commit d906120

Browse files
authored
Merge pull request Sub6Resources#911 from vrtdev/bugfix/830-table-rowspan
Improve table column bound calculation
2 parents c97ed78 + 9b50a5b commit d906120

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/src/layout_element.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,20 @@ class TableLayoutElement extends LayoutElement {
8888
}
8989

9090
// All table rows have a height intrinsic to their (spanned) contents
91-
final rowSizes =
92-
List.generate(rows.length, (_) => IntrinsicContentTrackSize());
91+
final rowSizes = List.generate(rows.length, (_) => IntrinsicContentTrackSize());
9392

9493
// Calculate column bounds
95-
int columnMax = rows
96-
.map((row) => row.children
97-
.whereType<TableCellElement>()
98-
.fold(0, (int value, child) => value + child.colspan))
99-
.fold(0, max);
94+
int columnMax = 0;
95+
List<int> rowSpanOffsets = [];
96+
for (final row in rows) {
97+
final cols = row.children.whereType<TableCellElement>().fold(0, (int value, child) => value + child.colspan) +
98+
rowSpanOffsets.fold<int>(0, (int offset, child) => child);
99+
columnMax = max(cols, columnMax);
100+
rowSpanOffsets = [
101+
...rowSpanOffsets.map((value) => value - 1).where((value) => value > 0),
102+
...row.children.whereType<TableCellElement>().map((cell) => cell.rowspan - 1),
103+
];
104+
}
100105

101106
// Place the cells in the rows/columns
102107
final cells = <GridPlacement>[];

0 commit comments

Comments
 (0)