From 4febead03aba35898ca4180e60dbc10c814ae090 Mon Sep 17 00:00:00 2001 From: Dan Cormier Date: Thu, 8 Oct 2026 17:28:53 -0400 Subject: [PATCH] fix(editor): restore V0 link text label --- .changeset/v0-link-text-label.md | 5 +++++ src/rich-text/plugins/link-editor.ts | 2 +- test/rich-text/editor.e2e.test.ts | 25 ++++++++++++++++++++++ test/rich-text/plugins/link-editor.test.ts | 24 +++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .changeset/v0-link-text-label.md diff --git a/.changeset/v0-link-text-label.md b/.changeset/v0-link-text-label.md new file mode 100644 index 00000000..46f4dc42 --- /dev/null +++ b/.changeset/v0-link-text-label.md @@ -0,0 +1,5 @@ +--- +"@stackoverflow/stacks-editor": patch +--- + +Restore the programmatic association between the visible Link text label and its form input in the V0 editor. diff --git a/src/rich-text/plugins/link-editor.ts b/src/rich-text/plugins/link-editor.ts index cebe4974..26ea8e1b 100644 --- a/src/rich-text/plugins/link-editor.ts +++ b/src/rich-text/plugins/link-editor.ts @@ -78,7 +78,7 @@ export class LinkEditor extends PluginInterfaceView< - +
diff --git a/test/rich-text/editor.e2e.test.ts b/test/rich-text/editor.e2e.test.ts index d1efb2c8..08449608 100644 --- a/test/rich-text/editor.e2e.test.ts +++ b/test/rich-text/editor.e2e.test.ts @@ -56,6 +56,31 @@ test.describe.serial("rich-text mode", () => { ); }); + test("should label link fields and save link text and destination", async () => { + await clearEditor(page); + await page.locator(editorSelector).focus(); + await page.locator(".js-insert-link-btn").click(); + + const linkUrl = page.getByRole("textbox", { + name: "Link URL", + exact: true, + }); + const linkText = page.getByRole("textbox", { + name: "Link text", + exact: true, + }); + await expect(linkUrl).toBeFocused(); + await linkUrl.fill("https://stackoverflow.com/"); + await page.keyboard.press("Tab"); + await expect(linkText).toBeFocused(); + await linkText.fill("Example link"); + await page.locator(".js-link-editor-save-btn").click(); + + expect(await getMarkdownContent(page)).toMatch( + /^\[Example link\]\(https:\/\/stackoverflow\.com\/\)\n?$/ + ); + }); + test("should insert heading from dropdown", async () => { await enterTextAsMarkdown(page, "plain text"); await page.locator(editorSelector).focus(); diff --git a/test/rich-text/plugins/link-editor.test.ts b/test/rich-text/plugins/link-editor.test.ts index fa499d9a..64da932b 100644 --- a/test/rich-text/plugins/link-editor.test.ts +++ b/test/rich-text/plugins/link-editor.test.ts @@ -55,6 +55,30 @@ describe("link-editor", () => { expect(updatedUploadContainer.parentElement).toBeTruthy(); }); + it("should associate each visible label with its input", () => { + showLinkEditor(view.editorView); + editor.update(view.editorView); + + const container = getViewContainer(editor); + const labels = + container.querySelectorAll("label"); + const inputs = [ + container.querySelector( + ".js-link-editor-href" + ), + container.querySelector( + ".js-link-editor-text" + ), + ]; + + expect(labels).toHaveLength(2); + labels.forEach((label, index) => { + expect(inputs[index]).toBeInstanceOf(HTMLInputElement); + expect(label.htmlFor).toBe(inputs[index]?.id); + expect(label.control).toBe(inputs[index]); + }); + }); + it("should focus first input when showing image uploader", () => { // we need to add our DOM to the doc's body in order to make jsdom's "focus" handling work // see https://github.com/jsdom/jsdom/issues/2586#issuecomment-742593116