fix: skip painting display:none subtrees (closes #21 display-none class)
Adds an early-return guard in paintNode so nodes with DISPLAY_NONE (already set on their Yoga node) are entirely skipped during paint, matching Ink's renderNodeToOutput behavior. Without the guard, hidden text/borders leaked onto visible siblings at x=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,3 +32,51 @@ test("display none", async () => {
|
||||
|
||||
// Skipped: display flex - concurrent
|
||||
// Skipped: display none - concurrent
|
||||
|
||||
test("display none after visible sibling does not corrupt output", async () => {
|
||||
const { lastFrame } = await render(
|
||||
defineComponent(() => () => (
|
||||
<Box flexDirection="row">
|
||||
<Text>AAA</Text>
|
||||
<Box display="none">
|
||||
<Text>BBBBB</Text>
|
||||
</Box>
|
||||
<Text>ZZ</Text>
|
||||
</Box>
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame({ trimLines: true })).toBe("AAAZZ");
|
||||
});
|
||||
|
||||
test("display none multi-line text adds no extra rows", async () => {
|
||||
const { lastFrame } = await render(
|
||||
defineComponent(() => () => (
|
||||
<Box flexDirection="column">
|
||||
<Text>top</Text>
|
||||
<Box display="none">
|
||||
<Text>{"h1\nh2\nh3"}</Text>
|
||||
</Box>
|
||||
<Text>bottom</Text>
|
||||
</Box>
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame({ trimLines: true })).toBe("top\nbottom");
|
||||
});
|
||||
|
||||
test("display none box does not paint its border", async () => {
|
||||
const { lastFrame } = await render(
|
||||
defineComponent(() => () => (
|
||||
<Box flexDirection="row">
|
||||
<Text>AAA</Text>
|
||||
<Box display="none" borderStyle="round">
|
||||
<Text>X</Text>
|
||||
</Box>
|
||||
<Text>ZZ</Text>
|
||||
</Box>
|
||||
)),
|
||||
{ columns: 100 },
|
||||
);
|
||||
expect(lastFrame({ trimLines: true })).toBe("AAAZZ");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user