Skip to content

layout: implement table rowspan geometry (#357)#361

Merged
carlos7ags merged 1 commit into
mainfrom
feat/table-rowspan-357
Jun 9, 2026
Merged

layout: implement table rowspan geometry (#357)#361
carlos7ags merged 1 commit into
mainfrom
feat/table-rowspan-357

Conversation

@carlos7ags

@carlos7ags carlos7ags commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Fixes #357.

Problem

rowspan was stored and used only to reserve grid occupancy so following rows skipped the spanned columns. The vertical geometry was never implemented: a spanning cell contributed height to its starting row only and was always drawn one row tall, so it appeared as a single row.

Fix

  • Add spanHeight to gridCell (the vertical analogue of spanWidth).
  • In buildGrid, exclude rowspanning cells from their starting row's natural height, then resolve span heights in a second pass: sum the spanned rows' heights plus the inter-row spacing gaps, growing the last spanned row when the cell's content needs more room.
  • drawTableRowDirect draws spanning cells at spanHeight. Vertical alignment already keys off the height argument, so content centers across the full span.

Preview

The new examples/table-rowspan demo (issue's minimal case + a 3-row schedule grid):

rowspan preview

Tests

  • TestTableRowspan — span covers both rows; non-spanning sibling has spanHeight == 0.
  • TestTableRowspanIncludesVerticalSpacing — span includes the inter-row gap.
  • TestTableRowspanDeficitGrowsLastRow — tall content grows the last spanned row.
  • TestTableRowspanThreeRows — 3-row span covers all rows plus both gaps.
  • TestTableColspanAndRowspanCombined — width and height span independently.
  • Example smoke test plus existing layout/colspan suites pass.

Known limitation

A rowspan that straddles a page break is not yet handled — PlanLayout's split logic is span-unaware, so such a cell draws its full height past the page bottom. Documented in a code comment; tracked in #362.

Rowspan was stored and used only to reserve grid occupancy so following
rows skipped the spanned columns. The vertical geometry was never
implemented: a spanning cell contributed height to its starting row only
and was always drawn one row tall, so it appeared as a single row.

Add spanHeight to gridCell (the vertical analogue of spanWidth). In
buildGrid, exclude rowspanning cells from their starting row's natural
height, then resolve span heights in a second pass: sum the spanned rows'
heights plus the inter-row spacing gaps, growing the last spanned row when
the cell's content needs more room. drawTableRowDirect draws spanning
cells at spanHeight; vertical alignment already keys off the height arg, so
content centers across the full span.

A rowspan that straddles a page break is not yet handled (the split logic
is span-unaware); documented as a known limitation.
@carlos7ags carlos7ags force-pushed the feat/table-rowspan-357 branch from 301cdcc to 3c89142 Compare June 9, 2026 00:45
@carlos7ags carlos7ags merged commit cae0607 into main Jun 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table row span does not work as expected

1 participant