fix: Box defaults to flexDirection='row', flexShrink=1, flexWrap='nowrap', flexGrow=0
Match Ink's Box defaults by setting yoga properties at node creation time. This ensures proper row-based layout regardless of Vue's prop patching order. Updated affected test snapshots and added explicit flexDirection="column" where tests relied on the old column default. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,10 +114,9 @@ test("Multiple Text elements inherit same background", async () => {
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[43m[43mHello [49m[43m[49m
|
||||
[43m[43mWorld[49m[43m [49m"
|
||||
`);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(
|
||||
`"[43m[43mHello [49m[43m[49m[43m[43mWorld[49m[43m[49m"`,
|
||||
);
|
||||
});
|
||||
|
||||
test("Mixed text with and without background inheritance", async () => {
|
||||
@@ -131,11 +130,9 @@ test("Mixed text with and without background inheritance", async () => {
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[42m[42mInherited [49m[42m[49m
|
||||
[42mNo BG [49m
|
||||
[42m[41mRed BG[49m[42m [49m"
|
||||
`);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(
|
||||
`"[42m[42mInherited [49m[42m[49m[42mNo BG [49m[42m[41mRed BG[49m[42m[49m"`,
|
||||
);
|
||||
});
|
||||
|
||||
test("Complex nested structure with background inheritance", async () => {
|
||||
@@ -153,11 +150,9 @@ test("Complex nested structure with background inheritance", async () => {
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[43m[43mOuter: [49m[43m [49m
|
||||
[44m[44mInner: [49m[44m [49m
|
||||
[44m[41mExplicit[49m[44m[49m"
|
||||
`);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(
|
||||
`"[43m[43mOuter: [49m[43m[49m[44m[44mInner: [49m[44m[49m[44m[41mExplicit[49m[44m[49m"`,
|
||||
);
|
||||
});
|
||||
|
||||
test("Box background with standard color", async () => {
|
||||
@@ -246,7 +241,7 @@ test("Box background fills entire area with standard color", async () => {
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[41m[41mHello[49m[41m [49m
|
||||
"[41m[41mHello[49m[41m[49m [49m
|
||||
[41m [49m
|
||||
[41m [49m"
|
||||
`);
|
||||
@@ -317,7 +312,7 @@ test("Box background with border fills content area", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[46m╭────────╮[49m
|
||||
[46m│[49m[46m[46mHi[49m[46m [49m[46m│[49m
|
||||
[46m│[49m[46m[46mHi[49m[46m[49m [49m[46m│[49m
|
||||
[46m│[49m[46m [49m[46m│[49m
|
||||
[46m│[49m[46m [49m[46m│[49m
|
||||
[46m╰────────╯[49m"
|
||||
@@ -335,7 +330,7 @@ test("Box background with padding fills entire padded area", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[45m [49m
|
||||
[45m [45m[45mHi[49m[45m [49m [49m
|
||||
[45m [45m[45mHi[49m[45m[49m [49m
|
||||
[45m [49m
|
||||
[45m [49m
|
||||
[45m [49m"
|
||||
@@ -358,8 +353,8 @@ test("Box background with center alignment fills entire area", async () => {
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[44m [49m
|
||||
[44m[44mHi[49m[44m [49m
|
||||
"[44m [44m[44mHi[49m[44m[49m [49m
|
||||
[44m [49m
|
||||
[44m [49m"
|
||||
`);
|
||||
});
|
||||
@@ -422,8 +417,8 @@ test("Box backgroundColor fills full width on every line when text wraps", async
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"[41m[41mHello [49m[41m [49m
|
||||
[41m[41mWorld!![49m[41m [49m"
|
||||
"[41m[41mHello [49m[41m [49m [49m
|
||||
[41m[41mWorld!![49m[41m[49m [49m"
|
||||
`);
|
||||
});
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ test("single node - box with horizontal alignment", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭──────────────────╮
|
||||
│Hello World │
|
||||
│ Hello World │
|
||||
╰──────────────────╯"
|
||||
`);
|
||||
});
|
||||
@@ -204,6 +204,14 @@ test("single node - box with vertical alignment", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭───────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│Hello World│
|
||||
│ │
|
||||
│ │
|
||||
@@ -214,14 +222,6 @@ test("single node - box with vertical alignment", async () => {
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰───────────╯"
|
||||
`);
|
||||
});
|
||||
@@ -377,7 +377,7 @@ test("multiple nodes - box with horizontal alignment", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭──────────────────╮
|
||||
│Hello World │
|
||||
│ Hello World │
|
||||
╰──────────────────╯"
|
||||
`);
|
||||
});
|
||||
@@ -394,6 +394,14 @@ test("multiple nodes - box with vertical alignment", async () => {
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭───────────╮
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│Hello World│
|
||||
│ │
|
||||
│ │
|
||||
@@ -404,14 +412,6 @@ test("multiple nodes - box with vertical alignment", async () => {
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
╰───────────╯"
|
||||
`);
|
||||
});
|
||||
@@ -486,11 +486,11 @@ test("nested boxes", async () => {
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭──────────────────────────────────────╮
|
||||
│ │
|
||||
│ ╭──────────────────────────────────╮ │
|
||||
│ │ │ │
|
||||
│ │ Hello World │ │
|
||||
│ │ │ │
|
||||
│ ╰──────────────────────────────────╯ │
|
||||
│ ╭─────────────╮ │
|
||||
│ │ │ │
|
||||
│ │ Hello World │ │
|
||||
│ │ │ │
|
||||
│ ╰─────────────╯ │
|
||||
│ │
|
||||
╰──────────────────────────────────────╯"
|
||||
`);
|
||||
@@ -515,17 +515,11 @@ test("nested boxes - fit-content box with wide characters on flex-direction row"
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭────────────╮
|
||||
│╭──────────╮│
|
||||
││ミスター ││
|
||||
│╰──────────╯│
|
||||
│╭──────────╮│
|
||||
││スポック ││
|
||||
│╰──────────╯│
|
||||
│╭──────────╮│
|
||||
││カーク船長││
|
||||
│╰──────────╯│
|
||||
╰────────────╯"
|
||||
"╭────────────────────────────────╮
|
||||
│╭────────╮╭────────╮╭──────────╮│
|
||||
││ミスター││スポック││カーク船長││
|
||||
│╰────────╯╰────────╯╰──────────╯│
|
||||
╰────────────────────────────────╯"
|
||||
`);
|
||||
});
|
||||
|
||||
@@ -548,17 +542,11 @@ test("nested boxes - fit-content box with emojis on flex-direction row", async (
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame()).toMatchInlineSnapshot(`
|
||||
"╭────╮
|
||||
│╭──╮│
|
||||
││🦾││
|
||||
│╰──╯│
|
||||
│╭──╮│
|
||||
││🌏││
|
||||
│╰──╯│
|
||||
│╭──╮│
|
||||
││😋││
|
||||
│╰──╯│
|
||||
╰────╯"
|
||||
"╭────────────╮
|
||||
│╭──╮╭──╮╭──╮│
|
||||
││🦾││🌏││😋││
|
||||
│╰──╯╰──╯╰──╯│
|
||||
╰────────────╯"
|
||||
`);
|
||||
});
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ test("remeasure text when text nodes are changed", async () => {
|
||||
const add = shallowRef(false);
|
||||
const { lastFrame } = await render(
|
||||
defineComponent(() => () => (
|
||||
<Box>
|
||||
<Box flexDirection="column">
|
||||
<Text>abc{add.value ? <Text>x</Text> : null}</Text>
|
||||
</Box>
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user