diff --git a/solvway-admin-portal/app/components/pages/BlockFields.tsx b/solvway-admin-portal/app/components/pages/BlockFields.tsx index 2fb9bee..d7b9b2c 100644 --- a/solvway-admin-portal/app/components/pages/BlockFields.tsx +++ b/solvway-admin-portal/app/components/pages/BlockFields.tsx @@ -73,7 +73,7 @@ export function BlockFields(props: { const richText = (labelCode: string) => ( - set({ html })} /> + set({ html })} /> ); diff --git a/solvway-admin-portal/app/components/pages/CmsBlocks.tsx b/solvway-admin-portal/app/components/pages/CmsBlocks.tsx index dd9d01d..66e4cf1 100644 --- a/solvway-admin-portal/app/components/pages/CmsBlocks.tsx +++ b/solvway-admin-portal/app/components/pages/CmsBlocks.tsx @@ -39,8 +39,8 @@ function Block({ block, index, company, slug, preview }: { block: PublicBlock; i case "HERO": return (
- -
+ +
{block.heading ?

{block.heading}

: null} {block.text ?

{block.text}

: null}
diff --git a/solvway-admin-portal/app/components/pages/PageEditor.test.tsx b/solvway-admin-portal/app/components/pages/PageEditor.test.tsx index 93139e7..b8da06a 100644 --- a/solvway-admin-portal/app/components/pages/PageEditor.test.tsx +++ b/solvway-admin-portal/app/components/pages/PageEditor.test.tsx @@ -35,6 +35,14 @@ beforeEach(() => { }); describe("PageEditor", () => { + it("names the rich text box after its field label", async () => { + const user = userEvent.setup(); + render(); + await screen.findByLabelText("Event"); + await user.click(screen.getByRole("button", { name: "Add Text" })); + expect(await screen.findByRole("textbox", { name: "Content" })).toHaveAttribute("contenteditable", "true"); + }); + it("loads a page, offers only events that have not ended, and saves the blocks in order", async () => { const user = userEvent.setup(); render(); diff --git a/solvway-admin-portal/app/components/pages/RichTextEditor.tsx b/solvway-admin-portal/app/components/pages/RichTextEditor.tsx index 776a5cd..dffccb2 100644 --- a/solvway-admin-portal/app/components/pages/RichTextEditor.tsx +++ b/solvway-admin-portal/app/components/pages/RichTextEditor.tsx @@ -14,8 +14,9 @@ const SAFE_LINK = /^(https:\/\/|mailto:|tel:|\/(?!\/))/i; const htmlOf = (editor: Editor) => (editor.isEmpty ? "" : editor.getHTML()); -export function RichTextEditor({ id, value, onChange, disabled, invalid }: { +export function RichTextEditor({ id, label, value, onChange, disabled, invalid }: { id?: string; + label?: string; value: string; onChange: (html: string) => void; disabled?: boolean; @@ -35,7 +36,7 @@ export function RichTextEditor({ id, value, onChange, disabled, invalid }: { }), TextAlign.configure({ types: ["heading", "paragraph"], alignments: ["left", "center", "right"] }), ], - editorProps: { attributes: { ...(id ? { id } : {}), ...(invalid ? { "aria-invalid": "true" } : {}), class: "min-h-[140px] px-3 py-2 text-sm outline-none" } }, + editorProps: { attributes: { ...(id ? { id } : {}), ...(label ? { "aria-label": label } : {}), ...(invalid ? { "aria-invalid": "true" } : {}), class: "min-h-[140px] px-3 py-2 text-sm outline-none" } }, onUpdate: ({ editor }) => { const html = htmlOf(editor); emitted.current = html;