From ba4333d79831792a1645db34e62773a0e1078313 Mon Sep 17 00:00:00 2001 From: Anton A S Date: Wed, 11 Mar 2026 00:54:49 +0300 Subject: [PATCH] Fix fill text MeasureFunc constraint, strengthen nested flex prompt layout.ts: When text fills width (stretch in col parent), MeasureFunc now uses Yoga's constraint width directly instead of clamping to the 100px default fixedWidth. prompt: Emphasize that ALL intermediate flex containers need w="fill", not just the first level. grow inside HUG = zero width. --- packages/core/src/layout.ts | 5 +++-- src/ai/system-prompt.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/layout.ts b/packages/core/src/layout.ts index 4f32cff03..b3dc9ae36 100644 --- a/packages/core/src/layout.ts +++ b/packages/core/src/layout.ts @@ -427,8 +427,9 @@ function configureTextLeaf( yogaChild.setWidth(fixedWidth) } yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => { - const constraintW = - widthMode === MeasureMode.Undefined ? fixedWidth : Math.min(width, fixedWidth || width) + const constraintW = fillsWidth + ? (widthMode === MeasureMode.Undefined ? fixedWidth : width) + : (widthMode === MeasureMode.Undefined ? fixedWidth : Math.min(width, fixedWidth || width)) const cacheKey = Math.round(constraintW) const cached = cache.get(cacheKey) if (cached) return cached diff --git a/src/ai/system-prompt.md b/src/ai/system-prompt.md index 146344082..9c5a2f76f 100644 --- a/src/ai/system-prompt.md +++ b/src/ai/system-prompt.md @@ -34,7 +34,7 @@ justify/items require flex — always declare flex="row" or flex="col" before us A hug parent shrinks to fit its children. A fill child stretches to its parent. These can't be circular — if the parent hugs, at least one child must have a concrete size. -Nested flex containers inside a column parent need w="fill" to stretch, otherwise they collapse to zero width. +Nested flex containers inside a column parent need w="fill" to stretch, otherwise they collapse to zero width. ⚠ This applies to ALL intermediate containers, not just the first level. If you have `flex="col" > flex="col" > flex="row"`, EVERY level needs w="fill". A `grow={1}` child inside a HUG parent gets zero width — the parent must have a concrete size (fixed w or w="fill"). There is no margin property. Padding on a container pushes all children equally from the edges. To offset a single child, wrap it in a Frame with its own padding.