Skip to content

fix: box-sizing behavior with borders - #116

Draft
natemoo-re wants to merge 1 commit into
mainfrom
fix/border-reserves-space
Draft

fix: box-sizing behavior with borders#116
natemoo-re wants to merge 1 commit into
mainfrom
fix/border-reserves-space

Conversation

@natemoo-re

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

Copy link
Copy Markdown
Member

renderer spec had an open decision (no. 4) on border box-sizing behavior because clay doesn't factor borders into layout, meaning that bordered boxes without padding would collapse over child text. in practice, this was a pure footgun. the band-aid userland fix was to adjust padding to compensate for borderWidth.

actual fix in this pr: resolve the spec's open question and update §12.2 to treat padding as max of user-defined padding or borderWidth. while this is the backwards compatible option, it's also slightly unintuitive and could be another footgun? opening the PR to settle now before breaking changes are too painful.

Clay doesn't account for border widths in layout — borders were drawn as
visual overlays, so any element with border width > padding had its content
collapsed behind the border glyphs (or, for fit-height boxes, collapsed to a
single row with top and bottom glyphs overlapping and children invisible).

Fix: at pack time, compute effective padding per side as
max(userPadding, borderWidth). Border glyphs draw in the same cells as before;
only the Clay layout values change so the engine reserves those cells.

Semantics of the max rule:
- No explicit padding: border width becomes the effective padding; content
  lands inside the border, not behind it.
- padding == borderWidth (prior workaround): max evaluates to the same value,
  no double-reservation; these elements render identically.
- padding > borderWidth: extra padding provides breathing room inside the
  border, measured from the border edge inward.

Callers who set padding == borderWidth as a workaround are unaffected.
Downstream compensators (e.g. lgtm.shop Panel) will render identically until
they drop the manual compensation on their next pin bump.

Resolves Open Decision #4 in specs/renderer-spec.md.
@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@116

commit: 6203ef3

@github-actions

Copy link
Copy Markdown

Size Increased — +0.3 KB

119.1 KB unpacked

@natemoo-re natemoo-re changed the title fix: bordered boxes reserve layout space for their border sides fix: box-sizing for borders Aug 23, 2026
@natemoo-re natemoo-re changed the title fix: box-sizing for borders fix: box-sizing with borders Aug 23, 2026
@natemoo-re natemoo-re changed the title fix: box-sizing with borders fix: box-sizing behavior with borders 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