fix(pages): keep the section toolbar inside the section #66
No files matched your search
@@ -102,7 +102,7 @@ export function ImageSpot({ index, src, className, corner }: { index: number; sr
|
||||
<>
|
||||
{img}
|
||||
<button type="button" aria-label={t("PagesImage")} onClick={open}
|
||||
className="absolute top-3 right-3 z-10 flex size-10 cursor-pointer items-center justify-center rounded-full bg-background/90 text-foreground shadow hover:bg-background">
|
||||
className="absolute top-3 left-3 z-10 flex size-10 cursor-pointer items-center justify-center rounded-full bg-background/90 text-foreground shadow hover:bg-background">
|
||||
<ImagePlus aria-hidden="true" className="size-5" />
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -119,7 +119,7 @@ export function VisualEditor({ p, ask }: { p: Draft; ask: Ask }) {
|
||||
<>
|
||||
{selected === i ? (
|
||||
<div role="toolbar" aria-label={t(BLOCK_LABELS[rows[i].block.type])} onClick={(e) => 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">
|
||||
<span draggable aria-label={t("PagesDragSection")} title={t("PagesDragSection")}
|
||||
className="flex size-8 cursor-grab items-center justify-center rounded-md hover:bg-accent"
|
||||
onDragStart={(e) => { e.dataTransfer.setData("text/plain", String(i)); e.dataTransfer.effectAllowed = "move"; setDrag({ from: i, to: null }); }}
|
||||
|
||||
Reference in new issue
Block a user