fix(pages): empty rich text on the canvas gets room and a faded cue

A new Text section was a thin line under its Add section button, with nothing
to click or read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-03 16:12:59 +08:00
1 parent cd3c2e1987
commit 68159086a9
2 files changed
+13 -1

No files matched your search

@@ -93,6 +93,15 @@ describe("LandingPage in edit mode", () => {
expect(screen.getAllByText("Body copy")).toHaveLength(1);
});
it("offers empty rich text as a spot to type: a faded cue that goes once there is text", async () => {
const { rerender } = render(<LandingPage company={company} page={page([{ type: "RICH_TEXT", html: "" }])} edit={editor()} preview />);
await screen.findByRole("textbox", { name: "Content" });
const cue = screen.getByText("Content", { selector: "p[aria-hidden]" });
expect(cue.parentElement!.className).toContain("[&_.ProseMirror]:min-h-24");
rerender(<LandingPage company={company} page={page([{ type: "RICH_TEXT", html: "<p>Hi</p>" }])} edit={editor()} preview />);
expect(screen.queryByText("Content", { selector: "p[aria-hidden]" })).not.toBeInTheDocument();
});
it("renders no editing without edit mode", () => {
render(<LandingPage company={company} page={page([{ type: "HERO", heading: "Hotel week" }, { type: "IMAGE_TEXT", heading: "Pic", imageId: 4 }])} />);
expect(document.querySelector("[contenteditable]")).toBeNull();
@@ -169,7 +169,10 @@ export function RichSpot({ index, html, className, children }: { index: number;
const edit = useEdit();
if (!edit) return <>{children}</>;
return (
<div className={className}>
<div className={`${className} relative ${html ? "" : "[&_.ProseMirror]:min-h-24"}`}>
{/* An empty editor is a thin line under the section's Add section button: it gets room, and a faded cue like
the plain fields' marks the spot to type. */}
{html ? null : <p aria-hidden="true" className="pointer-events-none absolute top-0 left-0 opacity-50">{t("PagesContent")}</p>}
<RichTextEditor bare label={t("PagesContent")} value={html ?? ""} onChange={(value) => edit.html(index, value)} />
</div>
);