Repository navigation
Give a Responsive that shows Empty no slot, in both renderers - #37
Merged
Merged
Conversation
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
Follow-up to #36. A
Responsivewhose visible variant isEmpty()still took a slot:For example,
Column, Gap 1: a, Responsive(At(0, Empty()), At(30, …)), bon a narrow screen gave 3 lines betweenaandbin the terminal and 2 gaps in the browser. It now gives one gap in both.TUI. After rendering its children, a Box drops those whose Responsive picked an empty variant at the width they were given, looking through
Keyedand nested Responsives. They're rendered first, so their picks stay recorded for the focus ring (#34). The check runs again after a wrapping Row collapses.Browser. The wrapper must stay a box because it's the query container, and container queries can only style descendants, never the wrapper itself. So for a Responsive with an
Emptyvariant directly inside a gapped Column:describe(which now knows the parent's gap) marks the wrapper and its empty variants, and adds a per-instance rule that cancels one gap with a negative end margin while the wrapper is flagged empty;ResizeObserveron such wrappers and sets the flag while an empty variant is the one displayed. ResizeObserver runs after layout and before paint, so there's no visible jump, and it tracks live window resizes.Not fixed: Rows. Inside a browser Row the wrapper reserves its widest breakpoint's width whatever it shows (the existing limitation from #5), and a gap correction can't remove that. I tried two ways to collapse it:
The limitation is now in the README. The TUI drops the slot in Rows too.
Test plan
rempty_test.go: Column with and without a gap, Row, Keyed and nested Responsive, both widths. Five of six cases fail on main. Also checks that focus picks stay aligned when a Responsive is dropped.vdom_test.go: the gap-cancel markup appears only for a gapped Column with an Empty variantTestResponsiveEmptyPickTakesNoSlot: one gap before the visible wide variant at 1000px. After a live resize to 300px, one gap between the siblings. With the cancel disabled it fails: "leaves 39.2px … want one gap (19.6px)".go test -race ./...,make e2e, both vets