Skip to content

feat(layout): add wrap support for row/column stacks#74

Merged
RtlZeroMemory merged 6 commits into
mainfrom
create-stack-wrap-layout
Feb 18, 2026
Merged

feat(layout): add wrap support for row/column stacks#74
RtlZeroMemory merged 6 commits into
mainfrom
create-stack-wrap-layout

Conversation

@RtlZeroMemory

Copy link
Copy Markdown
Owner

Summary

  • add wrap?: boolean to RowProps and ColumnProps (default remains false)
  • implement wrap-aware measure/layout for row and column stacks in stack.ts
  • apply justify/align per wrapped line and apply gap both within lines and between lines
  • run flex distribution per line in wrap mode (not globally)
  • keep non-wrap behavior unchanged

Tests

  • add packages/core/src/layout/__tests__/layout.wrap.test.ts with 28 deterministic wrap cases
  • run full validation:
    • npm run build
    • npm run typecheck
    • node scripts/run-tests.mjs (2486 passing)

Docs

  • update docs/guide/layout.md with a stack wrap section including percentage-size semantics in wrap mode

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a8c9f9bfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/layout/kinds/stack.ts Outdated
const childSizeRes = measureNode(child, cw, ch, "row");
if (!childSizeRes.ok) return childSizeRes;
const childMain = childSizeRes.value.w;
const childCross = align === "stretch" ? ch : childSizeRes.value.h;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive wrapped line cross-size before stretching children

With wrap: true and align: "stretch", this line sets each child’s cross size to the full container cross size (ch), so every wrapped line gets line.cross == ch; the subsequent lineY += line.cross + gap then pushes later lines by an entire container height instead of by that line’s intrinsic cross size. This produces visibly incorrect multi-line placement (and the same pattern exists in the column path), so line cross-size should be computed from measured children first and stretch should only be applied when laying out each child.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d81b073.

Changes:

  • wrapped line cross-size is now always derived from measured child intrinsic cross-size in both measurement and layout planning paths
  • align: "stretch" now only forces child cross-size during per-line layout (it no longer inflates line.cross to full container cross-size)
  • added regression tests:
    • row wrap align=stretch uses per-line intrinsic cross size
    • column wrap align=stretch uses per-line intrinsic cross size

Validation run: npm run lint, npm run build, npm run typecheck, node scripts/run-tests.mjs (all passing).

@RtlZeroMemory
RtlZeroMemory merged commit a441bba into main Feb 18, 2026
16 of 17 checks passed
@RtlZeroMemory
RtlZeroMemory deleted the create-stack-wrap-layout branch February 19, 2026 17:45
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