From fb6d1c10097df02c6e335d68e4bbc9fa95787b3a Mon Sep 17 00:00:00 2001 From: Matt Edmonston Date: Sat, 28 Nov 2026 10:45:47 +0000 Subject: [PATCH] Give a Responsive that shows Empty no slot, in both renderers 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. --- README.md | 1 + e2e/e2e_test.go | 28 +++++++++++++++ e2e/probe/main.go | 2 ++ rempty_test.go | 59 +++++++++++++++++++++++++++++++ render_tui.go | 47 +++++++++++++++++++++++-- render_wasm.go | 67 +++++++++++++++++++++++++++++++++++ vdom.go | 89 +++++++++++++++++++++++++++++++++++++++-------- vdom_test.go | 40 +++++++++++++++++++++ 8 files changed, 316 insertions(+), 17 deletions(-) create mode 100644 rempty_test.go diff --git a/README.md b/README.md index d7a0ed1..0a84171 100644 --- a/README.md +++ b/README.md @@ -1023,6 +1023,7 @@ The WASM binary includes none of the charmbracelet packages. The TUI binary incl ## Limitations (v1) +- **Responsive in a browser Row reserves its widest breakpoint** — the browser picks a variant with container queries, which need a box whose width does not depend on the variant shown, so inside a Row the wrapper takes up to its largest `MinWidth` (shrinking when the row is tight) whatever variant is visible, including an `Empty()` one. The TUI sizes it to the variant drawn. In a Column the two match, and an `Empty()` variant takes no space in either. - **Button focus keys derive from labels by default** — two buttons with the same label and no `WithID` in one view share TUI focus; give repeated buttons IDs. - **No theme system** — style is applied per-element inline (`Style.Merge` helps compose variants); in the browser the base stylesheet's `--wui-*` custom properties, `WithStylesheet` and `Style.Class` are the global styling hooks. - **TextArea editing is basic in the TUI** — typing, Enter, and Backspace append and delete at the end of the buffer; there is no cursor movement within the text. The browser build uses a native `