From e3d7b7ec4cb32172c6afb2515af7a4a2c6f6faf2 Mon Sep 17 00:00:00 2001 From: ngqile Date: Thu, 3 Dec 2026 17:48:04 +0800 Subject: [PATCH] fix(pages): keep the section toolbar inside the section so the canvas edge never clips it The toolbar hung 20 px above the selected section, so it was cut off for the first section and for any section scrolled to the top of the canvas. It now sits inside the section's top-right corner, and the hero's image button moves to the top-left so the two never overlap. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs --- solvway-admin-portal/app/components/pages/CmsEdit.tsx | 2 +- .../app/components/pages/visual/VisualEditor.test.tsx | 11 +++++++++++ .../app/components/pages/visual/VisualEditor.tsx | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/solvway-admin-portal/app/components/pages/CmsEdit.tsx b/solvway-admin-portal/app/components/pages/CmsEdit.tsx index 5fce674..97c90fb 100644 --- a/solvway-admin-portal/app/components/pages/CmsEdit.tsx +++ b/solvway-admin-portal/app/components/pages/CmsEdit.tsx @@ -102,7 +102,7 @@ export function ImageSpot({ index, src, className, corner }: { index: number; sr <> {img} diff --git a/solvway-admin-portal/app/components/pages/visual/VisualEditor.test.tsx b/solvway-admin-portal/app/components/pages/visual/VisualEditor.test.tsx index f890d67..007cbee 100644 --- a/solvway-admin-portal/app/components/pages/visual/VisualEditor.test.tsx +++ b/solvway-admin-portal/app/components/pages/visual/VisualEditor.test.tsx @@ -118,6 +118,17 @@ describe("VisualEditor", () => { expect(section(1)).toHaveAttribute("data-selected", "true"); }); + // A toolbar hung above the section was clipped at the canvas top (first section, or a section scrolled to the top). + it("keeps the section toolbar inside the section, clear of the hero's image button", async () => { + const canvas = await open(); + fireEvent.click(section(0)); + const bar = canvas.getByRole("toolbar"); + expect(bar.className).not.toMatch(/(^|\s)-top-/); + expect(bar.className).toMatch(/(^|\s)top-2(\s|$)/); + expect(bar.className).toMatch(/(^|\s)right-2(\s|$)/); + expect(within(section(0)).getByRole("button", { name: "Image" }).className).toMatch(/(^|\s)left-3(\s|$)/); + }); + it("undoes a delete with Ctrl+Z and redoes it with Ctrl+Shift+Z", async () => { const canvas = await open(); fireEvent.click(section(2)); diff --git a/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx b/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx index b3945cc..0662d28 100644 --- a/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx +++ b/solvway-admin-portal/app/components/pages/visual/VisualEditor.tsx @@ -119,7 +119,7 @@ export function VisualEditor({ p, ask }: { p: Draft; ask: Ask }) { <> {selected === i ? (
e.stopPropagation()} - className="absolute -top-5 right-2 z-30 flex items-center gap-0.5 rounded-md border bg-popover p-0.5 text-popover-foreground shadow-md"> + className="absolute top-2 right-2 z-30 flex items-center gap-0.5 rounded-md border bg-popover p-0.5 text-popover-foreground shadow-md"> { e.dataTransfer.setData("text/plain", String(i)); e.dataTransfer.effectAllowed = "move"; setDrag({ from: i, to: null }); }} -- 2.54.1