You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Element.HeightForWidth ignores child margins in the column branch #165
The column branch of Element.HeightForWidth (element_layout.go) measures every child at the full content width and sums the returned heights, ignoring the child's margins in both directions. The layout engine subtracts Margin.Horizontal() before measuring in recomputeTextWrapping and includes Margin.Vertical() in the main size, so a nested column reports a smaller height than layout gives its children.
Reproduction: a 29 character text ("aaaaa bbbbb ccccc ddddd eeeee") with WithMarginTRBL(0, 2, 0, 2) inside a column, which is itself a child of a column with WithWidth(20) followed by a text sibling. inner.HeightForWidth(20) returns 2, but the text is laid out 16 wide and wraps to 3 rows; the sibling is placed at Y=2 and overlaps the last line. The numbers are identical with WithAlign(AlignStart) on the inner column and with the default stretch. Putting the same text directly in the 20 wide column (no nesting) is correct: 16 wide, 3 rows, sibling at Y=3.
Likely fix: in that loop subtract child.style.Margin.Horizontal() from the available width before the stretch and clamp branches, and add child.style.Margin.Vertical() to totalH, then cover it with a nested-column case in element_layout_colwrap_test.go. Predates #162; noted during its review.
Activity
fix(layout): account for child margins in column HeightForWidth
fix(layout): measure non-stretch children at the width they receive (g…