feat(layout): add wrap support for row/column stacks#74
Conversation
There was a problem hiding this comment.
💡 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".
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 inflatesline.crossto 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).
Summary
wrap?: booleantoRowPropsandColumnProps(default remainsfalse)rowandcolumnstacks instack.tsjustify/alignper wrapped line and applygapboth within lines and between linesTests
packages/core/src/layout/__tests__/layout.wrap.test.tswith 28 deterministic wrap casesnpm run buildnpm run typechecknode scripts/run-tests.mjs(2486 passing)Docs
docs/guide/layout.mdwith a stack wrap section including percentage-size semantics in wrap mode