mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
fix(ui): fit the right side panel to its layout row so it is never clipped (#19864)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The web UI shows a resizable left sidebar, a center column, and a resizable right side panel > - On the chat page (and other layouts with a secondary sidebar), the right side panel can go past the right edge of the window > - Then the right part of the panel is cut off, and the close control is not visible > - Resizing the left sidebar or the panel does not bring it back > - This pull request makes the panel fit the space that its layout row actually has > - The benefit is that the panel always stays inside the window, at all sidebar and panel widths ## Linked Issues or Issue Description No public issue exists. I searched open PRs and issues for overflow, clipped, and right-panel problems and found no match. **What happened?** On the chat page, the right side panel went past the right edge of the window (or crushed the center thread under the 280px conversation list). At a 1280px window, with the left sidebar at 420px and a saved panel width of 624px, the right panel overflowed the available space in its layout row and clipped its right edge and close control. Dragging the panel or the sidebar did not fix it. **Expected behavior** With any sidebar and panel width, the panel stays inside the window with its close control visible, and the center column keeps a usable width. **Steps to reproduce** 1. Open the chat page for an agent and open the right side panel. 2. Drag the left sidebar to its maximum width (420px). 3. Drag the right panel to its maximum width. 4. Look at the right edge of the window or shrink the viewport to 900px: the panel overflows/clips. **Paperclip version or commit** Rebased onto `master` at `2d06567795`. ## What Changed - Cause: `PropertiesPanel` clamped its width to `window.innerWidth - 656`, assuming a fixed 236px left sidebar and no secondary sidebar in the row. The left sidebar can be up to 420px wide, and Agent Chat adds a 280px conversation list in the same row. - `ui/src/components/PropertiesPanel.tsx`: - `measureFittedPaneMax` measures the real space available for the panel: `row.getBoundingClientRect().right - main.getBoundingClientRect().left`. It preserves a 420px minimum center column down to the 260px panel minimum, and when total remaining space is below 260px, fits to that remaining space so the panel and its close control never clip past the row's right edge. - Displays `min(saved width, fitted width)` without overwriting the saved width in `localStorage`, so when space returns the panel grows back to the saved width. - Observes both the layout row and `#main-content` with `ResizeObserver` (plus window `resize`), so changes to the window, primary sidebar, or collapsible secondary rails (such as Agent Chat's collapsible conversation list) apply immediately. - Uses the fitted display width for drag start, drag clamping, and maximize restore glides, and keeps `widthRef` in sync during `pointermove` so fast `pointerup` persists the clamped drag width. - Falls back to window-based clamping when no `#main-content` exists in the row (for example, in isolated stories). - Leaves the classic fixed 320px panel unchanged. - `ui/src/components/PropertiesPanel.test.tsx`: focused regression suite covering layout-row fitting, narrow `<260px` desktop clamping, `#main-content` resize re-measurement when the row width is unchanged, drag start/clamping/persistence, and fallback without `#main-content`. ## Verification - RED before fix (on `2d06567795`): `pnpm --filter @paperclipai/ui exec vitest run src/components/PropertiesPanel.test.tsx` -> 3 failed / 1 passed (`Expected "260px", Received "624px"` and `Expected "372px", Received "624px"`). - GREEN after fix (`66adf42c82`): - `pnpm --filter @paperclipai/ui exec vitest run src/components/PropertiesPanel.test.tsx` -> 4/4 passed. - `pnpm --filter @paperclipai/ui typecheck` -> passed. - `pnpm check:token-gates` -> all 4 gates clean. - `node scripts/check-test-budget.mjs --files ui/src/components/PropertiesPanel.test.tsx` -> PASS. - Affected UI suite (217 files, 3,870 tests): 211 passed on initial parallel run and the 6 CPU-contention timed-out suites passed 6/6 (103/103 tests) on focused rerun. - Real-browser Chromium check against the built production UI (`server/ui-dist`) with left sidebar at 420px and saved panel width 624px: - Agent Chat 1280×800: `mainWidth=320`, `asideWidth=260`, `asideRight=1280`, `closeRight=1272`, `scrollWidth=1280`, saved width still `"624"`. - Agent Chat 900×800: `asideWidth=200`, `asideRight=900`, `closeRight=892`, `scrollWidth=900`. - Agent Chat 1440×900: `mainWidth=420`, `asideWidth=320`, `asideRight=1440`, `closeRight=1432`, `scrollWidth=1440`. - Task Detail 1280×800: `mainWidth=420`, `asideWidth=440`, `asideRight=1280`, `closeRight=1272`, `scrollWidth=1280`. - Task Detail 900×800: `mainWidth=220`, `asideWidth=260`, `asideRight=900`, `closeRight=892`, `scrollWidth=900`. ## Risks - Low risk. The production change is confined to `PropertiesPanel.tsx`. When the row has space, the panel width matches prior behavior. - When space is constrained, the panel narrows to fit the layout row rather than overflowing past the right edge of the window. - Layout measurement relies on `#main-content` rendered by `Layout`; when absent, the existing window-based clamp applies. ## Model Used - Original PR: Claude Opus 5.5 (`claude-opus-5-5`). - Rebase, `#main-content` ResizeObserver & drag-ref refinement, and verification: Antigravity (Google DeepMind) with shell, Vitest, and Playwright Chromium tools. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Dotta <bippadotta@protonmail.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2 files changed
+334
-11
No files matched your search
@@ -0,0 +1,279 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { act, type ReactNode } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { PropertiesPanel } from "./PropertiesPanel";
|
||||
|
||||
vi.mock("@/hooks/useCoordinatorWorkspaceEnabled", () => ({
|
||||
useCoordinatorWorkspaceEnabled: () => ({ enabled: false, loaded: true }),
|
||||
}));
|
||||
|
||||
const mockSandbox = vi.hoisted(() => ({ enabled: false }));
|
||||
vi.mock("@/context/DesignSandboxContext", () => ({ useDesignSandbox: () => mockSandbox.enabled }));
|
||||
|
||||
const mockInstanceSettingsApi = vi.hoisted(() => ({
|
||||
getExperimental: vi.fn(),
|
||||
}));
|
||||
vi.mock("@/api/instanceSettings", () => ({
|
||||
instanceSettingsApi: mockInstanceSettingsApi,
|
||||
}));
|
||||
|
||||
const mockPanelState = vi.hoisted(() => ({
|
||||
panelContent: null as ReactNode,
|
||||
panelContentMode: "padded" as const,
|
||||
panelVisible: true,
|
||||
panelMaximizeRequested: false,
|
||||
}));
|
||||
const mockSetPanelVisible = vi.hoisted(() => vi.fn());
|
||||
const mockClearPanelMaximizeRequest = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("../context/PanelContext", () => ({
|
||||
usePanel: () => ({
|
||||
panelContent: mockPanelState.panelContent,
|
||||
panelContentMode: mockPanelState.panelContentMode,
|
||||
panelVisible: mockPanelState.panelVisible,
|
||||
openPanel: vi.fn(),
|
||||
closePanel: vi.fn(),
|
||||
setPanelVisible: mockSetPanelVisible,
|
||||
togglePanelVisible: vi.fn(),
|
||||
panelMaximizeRequested: mockPanelState.panelMaximizeRequested,
|
||||
requestPanelMaximize: vi.fn(),
|
||||
clearPanelMaximizeRequest: mockClearPanelMaximizeRequest,
|
||||
}),
|
||||
}));
|
||||
|
||||
async function flushReact() {
|
||||
await act(async () => {
|
||||
for (let index = 0; index < 4; index += 1) {
|
||||
await Promise.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe("PropertiesPanel layout row fitting", () => {
|
||||
let container: HTMLDivElement;
|
||||
let root: Root | null = null;
|
||||
let originalInnerWidth: number;
|
||||
let originalResizeObserver: typeof ResizeObserver | undefined;
|
||||
let queryClient: QueryClient;
|
||||
|
||||
async function renderPanel({
|
||||
panelVisible = true,
|
||||
taskDetailLayout = true,
|
||||
content = <div data-testid="panel-content">content</div>,
|
||||
inLayoutRow = true,
|
||||
}: {
|
||||
panelVisible?: boolean;
|
||||
taskDetailLayout?: boolean;
|
||||
content?: ReactNode;
|
||||
inLayoutRow?: boolean;
|
||||
} = {}) {
|
||||
mockPanelState.panelContent = content;
|
||||
mockPanelState.panelVisible = panelVisible;
|
||||
root ??= createRoot(container);
|
||||
const panel = <PropertiesPanel taskDetailLayout={taskDetailLayout} />;
|
||||
await act(async () => {
|
||||
root!.render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TooltipProvider>
|
||||
{inLayoutRow ? (
|
||||
<div data-testid="layout-row">
|
||||
<div data-testid="chat-area">
|
||||
<main id="main-content" />
|
||||
</div>
|
||||
{panel}
|
||||
</div>
|
||||
) : panel}
|
||||
</TooltipProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
});
|
||||
await flushReact();
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
originalInnerWidth = window.innerWidth;
|
||||
originalResizeObserver = globalThis.ResizeObserver;
|
||||
Object.defineProperty(window, "innerWidth", { configurable: true, value: 1280 });
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
window.localStorage.clear();
|
||||
mockSetPanelVisible.mockClear();
|
||||
mockClearPanelMaximizeRequest.mockClear();
|
||||
mockPanelState.panelMaximizeRequested = false;
|
||||
mockSandbox.enabled = false;
|
||||
mockInstanceSettingsApi.getExperimental.mockResolvedValue({
|
||||
enableStreamlinedUi: true,
|
||||
enableClassicTaskInterface: false,
|
||||
});
|
||||
queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await act(async () => {
|
||||
root?.unmount();
|
||||
});
|
||||
root = null;
|
||||
container.remove();
|
||||
Object.defineProperty(window, "innerWidth", { configurable: true, value: originalInnerWidth });
|
||||
if (originalResizeObserver === undefined) {
|
||||
delete (globalThis as { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;
|
||||
} else {
|
||||
globalThis.ResizeObserver = originalResizeObserver;
|
||||
}
|
||||
vi.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
document.documentElement.style.removeProperty("--sz-420px");
|
||||
});
|
||||
|
||||
it("fits the pane to its layout row so it is never clipped at the right edge", async () => {
|
||||
window.localStorage.setItem("taskChatRedesign.taskDetailPropertiesPaneWidth", "624");
|
||||
const geometry = { rowRight: 1280, centerLeft: 700 };
|
||||
vi.spyOn(Element.prototype, "getBoundingClientRect").mockImplementation(function (this: Element) {
|
||||
if (this.id === "main-content") return new DOMRect(geometry.centerLeft, 0, 0, 800);
|
||||
if (this.getAttribute("data-testid") === "layout-row") return new DOMRect(0, 0, geometry.rowRight, 800);
|
||||
return new DOMRect();
|
||||
});
|
||||
|
||||
await renderPanel({ taskDetailLayout: true, inLayoutRow: true });
|
||||
const aside = container.querySelector("aside")!;
|
||||
const inner = aside.querySelector<HTMLDivElement>(":scope > div:not([role]) > div")!;
|
||||
expect(aside.style.width).toBe("260px");
|
||||
expect(inner.style.width).toBe("260px");
|
||||
|
||||
geometry.centerLeft = 488;
|
||||
await act(async () => {
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
});
|
||||
expect(aside.style.width).toBe("372px");
|
||||
expect(inner.style.width).toBe("372px");
|
||||
expect(window.localStorage.getItem("taskChatRedesign.taskDetailPropertiesPaneWidth")).toBe("624");
|
||||
|
||||
// Respects the shared --sz-420px minimum center width token when customized.
|
||||
document.documentElement.style.setProperty("--sz-420px", "460px");
|
||||
await act(async () => {
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
});
|
||||
expect(aside.style.width).toBe("332px");
|
||||
document.documentElement.style.removeProperty("--sz-420px");
|
||||
|
||||
geometry.rowRight = 1440;
|
||||
await act(async () => {
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
});
|
||||
expect(aside.style.width).toBe("532px");
|
||||
|
||||
// Narrow desktop where space right of center start is below the 260px minimum.
|
||||
geometry.rowRight = 900;
|
||||
geometry.centerLeft = 700;
|
||||
await act(async () => {
|
||||
window.dispatchEvent(new Event("resize"));
|
||||
});
|
||||
expect(aside.style.width).toBe("200px");
|
||||
expect(inner.style.width).toBe("200px");
|
||||
});
|
||||
|
||||
it("re-measures when #main-content shifts inside the row without the row resizing", async () => {
|
||||
window.localStorage.setItem("taskChatRedesign.taskDetailPropertiesPaneWidth", "624");
|
||||
const geometry = { rowRight: 1280, centerLeft: 700 };
|
||||
vi.spyOn(Element.prototype, "getBoundingClientRect").mockImplementation(function (this: Element) {
|
||||
if (this.id === "main-content") return new DOMRect(geometry.centerLeft, 0, 0, 800);
|
||||
if (this.getAttribute("data-testid") === "layout-row") return new DOMRect(0, 0, geometry.rowRight, 800);
|
||||
return new DOMRect();
|
||||
});
|
||||
|
||||
const observers = new Map<Element, ResizeObserverCallback[]>();
|
||||
class FakeResizeObserver {
|
||||
private readonly callback: ResizeObserverCallback;
|
||||
private readonly targets = new Set<Element>();
|
||||
constructor(callback: ResizeObserverCallback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
observe(target: Element) {
|
||||
this.targets.add(target);
|
||||
const list = observers.get(target) ?? [];
|
||||
list.push(this.callback);
|
||||
observers.set(target, list);
|
||||
}
|
||||
unobserve(target: Element) {
|
||||
this.targets.delete(target);
|
||||
}
|
||||
disconnect() {
|
||||
for (const target of this.targets) {
|
||||
const list = observers.get(target);
|
||||
if (list) {
|
||||
const next = list.filter((cb) => cb !== this.callback);
|
||||
if (next.length === 0) observers.delete(target);
|
||||
else observers.set(target, next);
|
||||
}
|
||||
}
|
||||
this.targets.clear();
|
||||
}
|
||||
}
|
||||
globalThis.ResizeObserver = FakeResizeObserver as unknown as typeof ResizeObserver;
|
||||
|
||||
await renderPanel({ taskDetailLayout: true, inLayoutRow: true });
|
||||
const aside = container.querySelector("aside")!;
|
||||
const main = container.querySelector("#main-content")!;
|
||||
expect(aside.style.width).toBe("260px");
|
||||
|
||||
// Simulate chat list collapsing inside chatAreaRef: #main-content shifts left,
|
||||
// while the outer layout row keeps the exact same width.
|
||||
geometry.centerLeft = 420;
|
||||
await act(async () => {
|
||||
for (const cb of observers.get(main) ?? []) {
|
||||
cb([], {} as ResizeObserver);
|
||||
}
|
||||
});
|
||||
expect(aside.style.width).toBe("440px");
|
||||
|
||||
// Simulate chat list reappearing on a tight row: #main-content shifts right again.
|
||||
geometry.rowRight = 900;
|
||||
geometry.centerLeft = 700;
|
||||
await act(async () => {
|
||||
for (const cb of observers.get(main) ?? []) {
|
||||
cb([], {} as ResizeObserver);
|
||||
}
|
||||
});
|
||||
expect(aside.style.width).toBe("200px");
|
||||
});
|
||||
|
||||
it("starts dragging from the fitted width and clamps drags to the layout row", async () => {
|
||||
window.localStorage.setItem("taskChatRedesign.taskDetailPropertiesPaneWidth", "624");
|
||||
vi.spyOn(Element.prototype, "getBoundingClientRect").mockImplementation(function (this: Element) {
|
||||
if (this.id === "main-content") return new DOMRect(488, 0, 0, 800);
|
||||
if (this.getAttribute("data-testid") === "layout-row") return new DOMRect(0, 0, 1280, 800);
|
||||
return new DOMRect();
|
||||
});
|
||||
|
||||
await renderPanel({ taskDetailLayout: true, inLayoutRow: true });
|
||||
const aside = container.querySelector("aside")!;
|
||||
const grip = aside.querySelector<HTMLDivElement>('[role="separator"][aria-label="Resize panel"]')!;
|
||||
grip.setPointerCapture = vi.fn();
|
||||
expect(aside.style.width).toBe("372px");
|
||||
|
||||
await act(async () => {
|
||||
grip.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, pointerId: 1, button: 0, pointerType: "mouse", clientX: 908 }));
|
||||
grip.dispatchEvent(new PointerEvent("pointermove", { bubbles: true, pointerId: 1, clientX: 708 }));
|
||||
});
|
||||
expect(aside.style.width).toBe("372px");
|
||||
|
||||
await act(async () => {
|
||||
grip.dispatchEvent(new PointerEvent("pointermove", { bubbles: true, pointerId: 1, clientX: 958 }));
|
||||
grip.dispatchEvent(new PointerEvent("pointerup", { bubbles: true, pointerId: 1, clientX: 958 }));
|
||||
});
|
||||
expect(aside.style.width).toBe("322px");
|
||||
expect(window.localStorage.getItem("taskChatRedesign.taskDetailPropertiesPaneWidth")).toBe("322");
|
||||
});
|
||||
|
||||
it("falls back to window-based clamping when mounted without #main-content", async () => {
|
||||
Object.defineProperty(window, "innerWidth", { configurable: true, value: 1000 });
|
||||
window.localStorage.setItem("taskChatRedesign.taskDetailPropertiesPaneWidth", "700");
|
||||
await renderPanel({ taskDetailLayout: true, inLayoutRow: false });
|
||||
const aside = container.querySelector("aside")!;
|
||||
expect(aside.style.width).toBe("344px");
|
||||
});
|
||||
});
|
||||
@@ -94,6 +94,9 @@ const TASK_DETAIL_DEFAULT_PANE_WIDTH = 434;
|
||||
const MIN_PANE_WIDTH = 260;
|
||||
/** ~236px sidebar + ~420px minimum center column stay usable while resizing. */
|
||||
const RESERVED_LAYOUT_WIDTH = 656;
|
||||
/** Fallback when `--sz-420px` is unavailable (e.g. non-browser test environments). */
|
||||
const MIN_CENTER_WIDTH_TOKEN = "--sz-420px";
|
||||
const MIN_CENTER_WIDTH_FALLBACK = 420;
|
||||
/** Content cap while maximized so text doesn't span the full viewport. */
|
||||
const MAXIMIZED_CONTENT_MAX_WIDTH = 840;
|
||||
/**
|
||||
@@ -103,20 +106,37 @@ const MAXIMIZED_CONTENT_MAX_WIDTH = 840;
|
||||
*/
|
||||
const RESTORE_FALLBACK_DELAY = 400;
|
||||
|
||||
function readProposalPaneWidth(fallback: number): number {
|
||||
function readCssPxToken(tokenName: string, fallback: number): number {
|
||||
if (typeof window === "undefined") return fallback;
|
||||
const tokenWidth = Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--design-page-aside-width"));
|
||||
const tokenWidth = Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(tokenName));
|
||||
return Number.isFinite(tokenWidth) && tokenWidth > 0 ? tokenWidth : fallback;
|
||||
}
|
||||
|
||||
function clampPaneWidth(width: number): number {
|
||||
function readProposalPaneWidth(fallback: number): number {
|
||||
return readCssPxToken("--design-page-aside-width", fallback);
|
||||
}
|
||||
|
||||
function clampPaneWidth(width: number, fittedMax: number | null = null): number {
|
||||
const max =
|
||||
typeof window === "undefined"
|
||||
fittedMax ??
|
||||
(typeof window === "undefined"
|
||||
? Number.POSITIVE_INFINITY
|
||||
: Math.max(MIN_PANE_WIDTH, window.innerWidth - RESERVED_LAYOUT_WIDTH);
|
||||
: Math.max(MIN_PANE_WIDTH, window.innerWidth - RESERVED_LAYOUT_WIDTH));
|
||||
return Math.min(Math.max(Math.round(width), MIN_PANE_WIDTH), max);
|
||||
}
|
||||
|
||||
function measureFittedPaneMax(aside: HTMLElement | null): number | null {
|
||||
const row = aside?.parentElement;
|
||||
const main = row?.querySelector<HTMLElement>("#main-content");
|
||||
if (!row || !main) return null;
|
||||
const rowRight = row.getBoundingClientRect().right;
|
||||
const centerLeft = main.getBoundingClientRect().left;
|
||||
if (rowRight <= centerLeft) return null;
|
||||
const available = Math.floor(rowRight - centerLeft);
|
||||
const minCenterWidth = readCssPxToken(MIN_CENTER_WIDTH_TOKEN, MIN_CENTER_WIDTH_FALLBACK);
|
||||
return Math.max(Math.min(MIN_PANE_WIDTH, available), available - minCenterWidth);
|
||||
}
|
||||
|
||||
function readStoredPaneWidth(storageKey: string, defaultWidth: number): number {
|
||||
if (typeof window === "undefined") return defaultWidth;
|
||||
try {
|
||||
@@ -207,8 +227,30 @@ function ResizablePropertiesPanel({
|
||||
}, [panelVisible]);
|
||||
|
||||
const asideRef = useRef<HTMLElement | null>(null);
|
||||
const [fittedMax, setFittedMax] = useState<number | null>(null);
|
||||
const fittedMaxRef = useRef(fittedMax);
|
||||
fittedMaxRef.current = fittedMax;
|
||||
const displayWidth = fittedMax === null ? width : Math.min(width, fittedMax);
|
||||
const widthRef = useRef(width);
|
||||
widthRef.current = width;
|
||||
const displayWidthRef = useRef(displayWidth);
|
||||
displayWidthRef.current = displayWidth;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!panelVisible) return;
|
||||
const row = asideRef.current?.parentElement;
|
||||
const main = row?.querySelector<HTMLElement>("#main-content");
|
||||
const update = () => setFittedMax(measureFittedPaneMax(asideRef.current));
|
||||
update();
|
||||
window.addEventListener("resize", update);
|
||||
const observer = (row || main) && typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
|
||||
if (row) observer?.observe(row);
|
||||
if (main) observer?.observe(main);
|
||||
return () => {
|
||||
window.removeEventListener("resize", update);
|
||||
observer?.disconnect();
|
||||
};
|
||||
}, [panelVisible]);
|
||||
const dragStateRef = useRef<{ pointerId: number; startX: number; startWidth: number } | null>(
|
||||
null,
|
||||
);
|
||||
@@ -262,7 +304,7 @@ function ResizablePropertiesPanel({
|
||||
dragStateRef.current = {
|
||||
pointerId: event.pointerId,
|
||||
startX: event.clientX,
|
||||
startWidth: widthRef.current,
|
||||
startWidth: displayWidthRef.current,
|
||||
};
|
||||
previousBodyUserSelectRef.current = document.body.style.userSelect;
|
||||
document.body.style.userSelect = "none";
|
||||
@@ -273,7 +315,9 @@ function ResizablePropertiesPanel({
|
||||
const drag = dragStateRef.current;
|
||||
if (drag === null || drag.pointerId !== event.pointerId) return;
|
||||
// The grip sits on the panel's LEFT border: moving left widens the panel.
|
||||
setWidth(clampPaneWidth(drag.startWidth + (drag.startX - event.clientX)));
|
||||
const next = clampPaneWidth(drag.startWidth + (drag.startX - event.clientX), fittedMaxRef.current);
|
||||
widthRef.current = next;
|
||||
setWidth(next);
|
||||
}, []);
|
||||
|
||||
const handleGripPointerUp = useCallback(
|
||||
@@ -335,7 +379,7 @@ function ResizablePropertiesPanel({
|
||||
const rowRight = row
|
||||
? row.getBoundingClientRect().right
|
||||
: window.innerWidth - pane.rightInset;
|
||||
return { ...pane, left: rowRight - widthRef.current };
|
||||
return { ...pane, left: rowRight - displayWidthRef.current };
|
||||
});
|
||||
clearRestoreTimer();
|
||||
restoreTimerRef.current = window.setTimeout(finishRestore, RESTORE_FALLBACK_DELAY);
|
||||
@@ -372,7 +416,7 @@ function ResizablePropertiesPanel({
|
||||
<div
|
||||
aria-hidden
|
||||
className="hidden md:block shrink-0"
|
||||
style={{ width: panelVisible ? width : 0 }}
|
||||
style={{ width: panelVisible ? displayWidth : 0 }}
|
||||
/>
|
||||
) : null}
|
||||
<aside
|
||||
@@ -399,7 +443,7 @@ function ResizablePropertiesPanel({
|
||||
left: fixedPane.left,
|
||||
right: fixedPane.rightInset,
|
||||
}
|
||||
: { width: panelVisible ? width : 0, opacity: panelVisible ? 1 : 0 }
|
||||
: { width: panelVisible ? displayWidth : 0, opacity: panelVisible ? 1 : 0 }
|
||||
}
|
||||
onTransitionEnd={handleTransitionEnd}
|
||||
>
|
||||
@@ -429,7 +473,7 @@ function ResizablePropertiesPanel({
|
||||
<div className="flex min-h-0 flex-1 overflow-hidden">
|
||||
<div
|
||||
className={cn("flex shrink-0 flex-col min-h-0", !maximized && "border-l border-border", isFixed && "w-full")}
|
||||
style={isFixed ? undefined : { width, minWidth: width }}
|
||||
style={isFixed ? undefined : { width: displayWidth, minWidth: displayWidth }}
|
||||
>
|
||||
<SidePanelFrame
|
||||
presentation="docked"
|
||||
|
||||
Reference in new issue
Block a user