Skip to content

Commit 8ca8fe2

Browse files
fix(ui): keep Review file previews within panel (#132800)
* fix(ui): keep Review file previews within panel * test(ui): exercise Review panel flex boundary
1 parent d3c07b0 commit 8ca8fe2

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

‎ui/src/pages/chat/components/chat-sidebar-file-view.browser.test.ts‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expectDefined } from "@openclaw/normalization-core";
22
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
33
import "../../../styles.css";
4+
import "../../../styles/chat.css";
45
import "./chat-sidebar.ts";
56

67
// The root jsdom ui shard also collects *.browser.test.ts files; CodeMirror
@@ -42,13 +43,23 @@ type DetailPanel = HTMLElement & {
4243
updateComplete: Promise<unknown>;
4344
};
4445

45-
const mounted: DetailPanel[] = [];
46+
const mounted: HTMLElement[] = [];
4647

47-
async function mountFile(content: FileSidebarContent): Promise<DetailPanel> {
48+
async function mountFile(content: FileSidebarContent, width?: number): Promise<DetailPanel> {
4849
const panel = document.createElement("openclaw-chat-detail-panel") as DetailPanel;
4950
panel.content = content;
50-
document.body.append(panel);
51-
mounted.push(panel);
51+
if (width === undefined) {
52+
document.body.append(panel);
53+
mounted.push(panel);
54+
} else {
55+
const container = document.createElement("div");
56+
container.className = "side-panel__panel";
57+
container.style.cssText = `display:flex;width:${width}px;height:320px;`;
58+
panel.className = "chat-sidebar";
59+
container.append(panel);
60+
document.body.append(container);
61+
mounted.push(container);
62+
}
5263
await panel.updateComplete;
5364
await expect.poll(() => panel.querySelector(".cm-editor"), { timeout: 5_000 }).not.toBeNull();
5465
return panel;
@@ -72,6 +83,26 @@ afterEach(() => {
7283
});
7384

7485
describe.runIf(browserMode)("chat file editor", () => {
86+
it("keeps long lines inside Review and gives horizontal scroll to the editor", async () => {
87+
const panel = await mountFile(
88+
{
89+
kind: "file",
90+
path: "src/long-line.ts",
91+
name: "long-line.ts",
92+
content: `export const value = "${"long-content-".repeat(80)}";`,
93+
},
94+
320,
95+
);
96+
97+
const fileView = panel.querySelector<HTMLElement>(".file-view")!;
98+
const scroller = panel.querySelector<HTMLElement>(".cm-scroller")!;
99+
await expect.poll(() => fileView.clientWidth).toBeGreaterThan(0);
100+
expect(fileView.clientWidth).toBeLessThanOrEqual(panel.parentElement!.clientWidth);
101+
expect(fileView.scrollWidth).toBe(fileView.clientWidth);
102+
expect(scroller.scrollWidth).toBeGreaterThan(scroller.clientWidth);
103+
expect(getComputedStyle(scroller).overflowX).toBe("auto");
104+
});
105+
75106
it("renders content and decorates the requested line", async () => {
76107
const panel = await mountFile({
77108
kind: "file",

‎ui/src/styles/chat/sidebar.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ openclaw-chat-sidebar-region,
15641564
display: flex;
15651565
flex: 1;
15661566
flex-direction: column;
1567+
min-width: 0;
15671568
min-height: 0;
15681569
}
15691570

0 commit comments

Comments
 (0)