fix(studio): show Layers full-height in the flat inspector, not split with Design

The flat inspector split Layers and Design into a vertically-resizable
stacked pair whenever both panes were toggled on, mirroring the legacy
panel's layout. For the flat redesign this reads as two competing panels
crammed into one column; Layers should always render full-height by
itself there instead.

Gate the split-view branch behind !STUDIO_FLAT_INSPECTOR_ENABLED so it
still applies to the legacy panel, and fall through to Layers rendering
alone (the existing `layersPaneOpen` branch already does this — it just
never got reached previously because the split check ran first).

Also added setExclusiveRightInspectorPane (radio-style: selecting one pane
turns the other off) and use it for the Design/Layers tab clicks under the
flat flag, since leaving both panes independently toggleable would highlight
both tabs as "active" while only one actually renders.

New usePanelLayout.test.ts covers both the existing toggle behavior and the
new exclusive variant. Full studio suite (2634 tests) green; typecheck/
oxlint/oxfmt clean.
This commit is contained in:
Vance Ingalls
2026-07-15 19:05:38 -07:00
parent c621fd0f29
commit 79b688f204
4 changed files with 95 additions and 2 deletions
@@ -0,0 +1,70 @@
// @vitest-environment happy-dom
import React, { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, it } from "vitest";
import { usePanelLayout } from "./usePanelLayout";
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
afterEach(() => {
document.body.innerHTML = "";
});
function renderPanelLayout() {
const host = document.createElement("div");
document.body.append(host);
const root = createRoot(host);
let current: ReturnType<typeof usePanelLayout> | null = null;
function Harness() {
current = usePanelLayout();
return null;
}
act(() => {
root.render(React.createElement(Harness));
});
return {
getState: (): ReturnType<typeof usePanelLayout> => {
if (!current) throw new Error("usePanelLayout did not render");
return current;
},
unmount: () => act(() => root.unmount()),
};
}
describe("usePanelLayout — right inspector panes", () => {
it("toggleRightInspectorPane independently flips one pane, allowing both open at once", () => {
const harness = renderPanelLayout();
expect(harness.getState().rightInspectorPanes).toEqual({ layers: false, design: true });
act(() => harness.getState().toggleRightInspectorPane("layers"));
expect(harness.getState().rightInspectorPanes).toEqual({ layers: true, design: true });
harness.unmount();
});
it("toggleRightInspectorPane refuses to turn off the last remaining pane", () => {
const harness = renderPanelLayout();
act(() => harness.getState().toggleRightInspectorPane("design"));
// Only "design" was on; toggling it off would leave both false — guarded.
expect(harness.getState().rightInspectorPanes).toEqual({ layers: false, design: true });
harness.unmount();
});
it("setExclusiveRightInspectorPane is radio-style — selecting one turns the other off", () => {
const harness = renderPanelLayout();
act(() => harness.getState().toggleRightInspectorPane("layers"));
expect(harness.getState().rightInspectorPanes).toEqual({ layers: true, design: true });
act(() => harness.getState().setExclusiveRightInspectorPane("layers"));
expect(harness.getState().rightInspectorPanes).toEqual({ layers: true, design: false });
act(() => harness.getState().setExclusiveRightInspectorPane("design"));
expect(harness.getState().rightInspectorPanes).toEqual({ layers: false, design: true });
harness.unmount();
});
});