Repository navigation
Fix TUI Column gap off-by-one and Empty children taking a slot - #36
Merged
Merged
Conversation
A Column's gap was joined as a part of Gap newlines, which lipgloss.JoinVertical draws as Gap+1 lines, so every gapped Column (and every collapsed wrapping Row) had one blank line too many per gap. Fill-height columns budgeted Gap lines per gap, so they also overflowed their height. The gap part is now Gap-1 newlines. Empty children (When(false, ...), If(false, ...), nil, Keyed Empty) were laid out as a blank slot with a gap on each side, in Columns and Rows alike, while in the browser an empty comment node is not a flex item and takes no gap. Boxes now lay out only their non-empty children. Closes #35
4 tasks done
archlemon
added a commit
that referenced
this pull request
Nov 28, 2026
Following the Empty fix in #36, a Responsive whose visible variant is Empty still took a slot: in the TUI a blank line plus a gap on each side, in the browser a zero-height wrapper with a gap on each side. TUI: a Box drops children whose Responsive picks an empty variant at the width they were given (after rendering them, so their picks stay recorded for the focus ring), re-checking after a wrap collapse. Browser: the wrapper must stay a box for its container queries, and those cannot style the wrapper itself. In a gapped Column, a Responsive with an Empty variant now carries a per-instance rule that cancels one gap with a negative end margin while the wrapper is flagged empty, and the renderer keeps the flag current with a ResizeObserver, which runs after layout and before paint. In a Row the browser wrapper still reserves its widest breakpoint's width; that existing limitation is now documented in the README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #35. Both claims are confirmed with the repro from the issue, plus a few related cases the probe turned up.
1. Column gap off by one.
renderBoxjoined a gap part ofGapnewlines, andlipgloss.JoinVerticaldraws that asGap+1lines. The gap part is nowGap-1newlines.Column, Gap: 1, a, b"a\n \n \nb""a\n \nb"Column, Gap: 2, a, bWrapRow,Gap: 2Related:
distributeColumnbudgetsGap*(n-1)lines for gaps, so a Fill-height Column with a gap overflowed its height by one line per gap. With the drawing fixed, it fits.2. Empty children took a slot.
Empty()(andWhen(false, …),If(false, …), nil,Keyed(k, Empty())) rendered as""and still got a line plus a gap on each side. Beyond what the issue lists, this also happened:"a\n \nb";Row, Gap: 1, a, Empty, bgave"a b".In the browser an empty comment node is not a flex item and takes no gap.
renderBoxnow lays out only non-empty children (laidOutChildren). Grow, Wrap and distribution all use the filtered list, and focus collection was already unaffected.Also guarded the gap join for fewer than two parts, which would have panicked on a Box whose children are all empty.
Browser side
The issue says the browser already gets this right. New e2e test
TestColumnGapIsOneLineAndSkipsEmptyconfirms it: aGap: 1column leaves exactly one line between items in Chromium, and a hiddenWhenbetween them adds no space.Test plan
gap_test.go: the gap counts, hiddenWhen, gap-0 Empty, keyed Empty, Row with Empty, leading and trailing Empty, all-Empty children, collapsed wrap gap, and Fill-height column with a gap. All fail on main.go test -race ./...,make e2e, both vetsKnown remaining difference: a multi-variant
Responsivewhose visible variant isEmptystill takes a slot in both renderers. The browser keeps its wrapperdivas a zero-height flex item, so the two differ by that one line. Left as is; it needs a browser-side change too.