fix: Text node defaults to flexDirection='row' matching Ink's ink-text

Set flexDirection=row, flexShrink=1, flexGrow=0 on text yoga nodes at
creation time, matching Ink's <ink-text> style defaults.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-26 00:52:37 +08:00
parent 2e1493b785
commit b8778c1847
2 changed files with 48 additions and 0 deletions
+8
View File
@@ -59,6 +59,14 @@ export function attachYoga(node: YogaCarrier): void {
(node.yoga as YogaNode).setFlexWrap(Yoga.WRAP_NO_WRAP);
(node.yoga as YogaNode).setFlexGrow(0);
}
// Text nodes match Ink's <ink-text> defaults: row direction, shrinkable.
// Although text nodes rarely have yoga-carrying children, this ensures
// consistent layout behavior matching Ink.
if (node.type === "text") {
(node.yoga as YogaNode).setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
(node.yoga as YogaNode).setFlexShrink(1);
(node.yoga as YogaNode).setFlexGrow(0);
}
}
export function detachYoga(node: YogaCarrier): void {