History

fix(web): keep pull request panel within viewport (#6451)

Bilal Bakr committed 3 months ago

Commit 97db94c1 parent 5015d7c2 files · +12 −2Browse files

Unified · Split

2 files
  1. apps/web/src/components/preview/PreviewPanelShell.test.ts +11 −1
  2. apps/web/src/components/preview/PreviewPanelShell.tsx +1 −1
apps/web/src/components/preview/PreviewPanelShell.test.ts+11−1
@@ -1,6 +1,8 @@
1+import { jsx } from "react/jsx-runtime";
2+import { renderToStaticMarkup } from "react-dom/server";
13 import { describe, expect, it } from "vite-plus/test";
24
3−import { getPreviewPanelMaxWidth } from "./PreviewPanelShell";
5+import { getPreviewPanelMaxWidth, PreviewPanelShell } from "./PreviewPanelShell";
46
57 describe("getPreviewPanelMaxWidth", () => {
68 it("allows the panel to use 70% of an ultra-wide viewport without a pixel ceiling", () => {
@@ -10,4 +12,12 @@ describe("getPreviewPanelMaxWidth", () => { · 3 unmodified lines
1012 it("rounds fractional CSS pixels down", () => {
1113 expect(getPreviewPanelMaxWidth(2_001)).toBe(1_400);
1214 });
15+
16+ it("keeps inline panels inside their containing workspace", () => {
17+ const markup = renderToStaticMarkup(
18+ jsx(PreviewPanelShell, { mode: "inline", defaultWidth: 1_000, children: "Panel" }),
19+ );
20+
21+ expect(markup).toContain("max-w-full");
22+ });
1323 });
apps/web/src/components/preview/PreviewPanelShell.tsx+1−1
@@ -51,7 +51,7 @@ export function PreviewPanelShell(props: { · 50 unmodified lines
5151 return (
5252 <div
5353 className={cn(
54− "relative flex h-full min-h-0 min-w-0 flex-col self-stretch bg-background",
54+ "relative flex h-full min-h-0 min-w-0 max-w-full flex-col self-stretch bg-background",
5555 isInline
5656 ? props.maximized
5757 ? "flex-1 border-l border-border"