Skip to content

fix: nested grow() children overflow parent padding on grow()-sized padded roots - #115

Draft
natemoo-re wants to merge 2 commits into
mainfrom
fix/nested-grow-right-padding
Draft

fix: nested grow() children overflow parent padding on grow()-sized padded roots#115
natemoo-re wants to merge 2 commits into
mainfrom
fix/nested-grow-right-padding

Conversation

@natemoo-re

@natemoo-re natemoo-re commented Aug 23, 2026

Copy link
Copy Markdown
Member
  • grow() children under a padded grow()-sized parent overflowed or were clipped past the parent's right and bottom padding; an identical tree under a fixed()-sized parent laid out correctly

  • root cause: Clay__CloseElement set minDimensions from content-derived size for GROW elements; for a grow() root with padding, minDimensions.width = text_width + padding exceeded terminal width, so SizeContainersAlongAxis refused to compress the root below that minimum

  • fix: GROW elements' minimum compressible size is now the user-configured min (default 0), not natural content size; non-GROW types unchanged; both width and height axes covered

  • applied as patches/clay-grow-minDimensions.patch at build time, same pattern as patches/clay-disable-debug-tools.patch; idempotent, reverted by make clean; long-term destination is upstream nicbarker/clay

  • specs/renderer-spec.md §8.4 now states that grow() min is the configured min, not content size

  • 4 regression tests: fixed() vs grow() root identical positions, asymmetric padding, two-level nesting, height-axis bounds.height check

Clay's CloseElement set minDimensions from content-derived size for all
element types, including GROW. For a GROW root with right padding, the
content-derived minDimensions.width was text_width + padding, which
exceeded the terminal width. SizeContainersAlongAxis then refused to
compress the root below that minimum, so the root overflowed the
terminal and nested grow() spacers were clipped past the parent's right
(and bottom) padding.

The fix: GROW elements resolve against the parent content box, so their
minimum compressible size is the user-configured min (default 0), not
the natural size of their content. Non-GROW types are unchanged.

Applied via patches/clay-grow-minDimensions.patch at build time,
following the same pattern as patches/clay-disable-debug-tools.patch
from ref/clay-debug-tools. The Makefile applies the patch idempotently
before compilation and restores clay/clay.h on `make clean`.

specs/renderer-spec.md §8.4 updated to document the content-box
semantics: grow() minimum is the configured min, not content size.
Four cases covering the fixed behavior:
(a) fixed() and grow() roots produce identical child positions for a
    right-aligned row (text + grow spacer + text) with symmetric padding.
(b) grow() root with asymmetric padding — R lands at the correct column
    respecting the larger right pad, not overflowing it.
(c) Two levels of grow() nesting — each box preserves its own content
    box so R remains inside the innermost right padding.
(d) Height axis — grow() root bounds.height equals terminal height even
    when content rows + vertical padding exceed it (catches the same
    minDimensions bug on the Y axis).
@pkg-pr-new

pkg-pr-new Bot commented Aug 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@115

commit: e7a31bd

@natemoo-re natemoo-re changed the title fix(layout): grow() elements respect parent content box when sizing fix: nested grow() children overflow parent padding on grow()-sized padded roots Aug 23, 2026
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.

1 participant