fix: hide empty tile stack sections so closed editors add no lines

This commit is contained in:
LukeGus committed 2026-11-06 18:19:00 -06:00
1 parent 76d41a2cbb
commit 191d5b2e57
2 files changed
+14 -1

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ export function TileStack({
{Children.toArray(children).map((section, index) => (
<div
key={keyOf(section, index)}
className="min-w-0 shrink-0 border-b border-border [&>[data-slot=toolbar-band]]:border-b-0"
className="min-w-0 shrink-0 border-b border-border empty:hidden [&>[data-slot=toolbar-band]]:border-b-0"
>
{section}
</div>
@@ -113,6 +113,19 @@ describe("TileStack", () => {
expect(screen.getByText("first").parentElement).toHaveClass("border-b");
expect(screen.getByText("second").parentElement).toHaveClass("border-b");
});
it("hides a section whose child renders nothing, like a closed editor", () => {
const Closed = () => null;
const { container } = render(
<TileStack>
<span>first</span>
<Closed />
</TileStack>,
);
const sections = container.querySelectorAll(".border-b");
expect(sections[sections.length - 1]).toHaveClass("empty:hidden");
expect(sections[sections.length - 1]).toBeEmptyDOMElement();
});
});
describe("cards outside a tile layout", () => {