From 67ed3ab47a9647def1ace2d25b0b373811f1ac1c Mon Sep 17 00:00:00 2001 From: Alex Warren Date: Wed, 16 Sep 2026 16:22:25 +0100 Subject: [PATCH 1/2] fix(editor): associate link text label A11Y-196 --- .changeset/a11y-link-text-label.md | 5 +++++ src/rich-text/plugins/link-editor.ts | 2 +- test/rich-text/plugins/link-editor.test.ts | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/a11y-link-text-label.md diff --git a/.changeset/a11y-link-text-label.md b/.changeset/a11y-link-text-label.md new file mode 100644 index 00000000..3d6d97a9 --- /dev/null +++ b/.changeset/a11y-link-text-label.md @@ -0,0 +1,5 @@ +--- +"@stackoverflow/stacks-editor": patch +--- + +Associate the visible link text label with its form input. 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/plugins/link-editor.test.ts b/test/rich-text/plugins/link-editor.test.ts index fa499d9a..c0ff0d28 100644 --- a/test/rich-text/plugins/link-editor.test.ts +++ b/test/rich-text/plugins/link-editor.test.ts @@ -55,6 +55,23 @@ 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"); + + expect(labels).toHaveLength(2); + labels.forEach((label) => { + expect(label.htmlFor).not.toBe(""); + expect( + container.querySelector(`#${label.htmlFor}`) + ).toBeInstanceOf(HTMLInputElement); + }); + }); + 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 From f2262bdce2b9b17f75607369327774ff3a5533bc Mon Sep 17 00:00:00 2001 From: Alex Warren Date: Wed, 16 Sep 2026 16:33:26 +0100 Subject: [PATCH 2/2] test(editor): verify link label targets A11Y-196 --- test/rich-text/plugins/link-editor.test.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/rich-text/plugins/link-editor.test.ts b/test/rich-text/plugins/link-editor.test.ts index c0ff0d28..a5665877 100644 --- a/test/rich-text/plugins/link-editor.test.ts +++ b/test/rich-text/plugins/link-editor.test.ts @@ -62,13 +62,19 @@ describe("link-editor", () => { 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) => { - expect(label.htmlFor).not.toBe(""); - expect( - container.querySelector(`#${label.htmlFor}`) - ).toBeInstanceOf(HTMLInputElement); + labels.forEach((label, index) => { + expect(inputs[index]).toBeInstanceOf(HTMLInputElement); + expect(label.htmlFor).toBe(inputs[index]?.id); }); });