From 7adde99113275a33f51079a3dba57e608e9b868a Mon Sep 17 00:00:00 2001 From: Santiago Regusci Date: Thu, 12 Nov 2026 12:23:53 -0300 Subject: [PATCH 1/2] Editor info link: "Annotation Editor Help" as tooltip and accessible name The tooltip of the info link above the annotation editor is now "Annotation Editor Help". The link's accessible name is now the same text. Before, the link had a `title` and a longer, different `aria-label`. A browser then uses the `title` as the link's description, so a screen reader read the tooltip out a second time after the name, and with a new tooltip the two would have said different things. Now what is shown on hover is what is announced, and what voice control listens for. The rest of the old name, "Learn what this text field is for. Opens Help Center article in a new tab.", is the link's description (`aria-describedby`). The element that holds it is `hidden`, so it is read only as the description and not again as text after the link. Its id comes from `useId`, so two editors open at once do not share one. Nothing else about the link changes, and it is still behind the `annotation_editor_info` flag. Part of hypothesis/product-backlog#1753. Co-Authored-By: Claude Fable 5.2 --- .../Annotation/AnnotationEditor.tsx | 2 +- src/sidebar/components/MarkdownEditor.tsx | 23 +++++-- .../components/test/MarkdownEditor-test.js | 69 +++++++++++++++++-- 3 files changed, 83 insertions(+), 11 deletions(-) diff --git a/src/sidebar/components/Annotation/AnnotationEditor.tsx b/src/sidebar/components/Annotation/AnnotationEditor.tsx index 7b58fa65d5c..f100ce8185a 100644 --- a/src/sidebar/components/Annotation/AnnotationEditor.tsx +++ b/src/sidebar/components/Annotation/AnnotationEditor.tsx @@ -79,7 +79,7 @@ function AnnotationEditor({ // which link to external websites. const showHelpLink = serviceConfig(settings)?.enableHelpPanel ?? true; - // The "About the Annotation editor" link also goes to an external website, + // The "Annotation Editor Help" link also goes to an external website, // so it follows the same rule, on top of its feature flag. const showEditorInfoLink = showHelpLink && store.isFeatureEnabled('annotation_editor_info'); diff --git a/src/sidebar/components/MarkdownEditor.tsx b/src/sidebar/components/MarkdownEditor.tsx index 4cb943a96cb..44428c9f035 100644 --- a/src/sidebar/components/MarkdownEditor.tsx +++ b/src/sidebar/components/MarkdownEditor.tsx @@ -554,8 +554,16 @@ function Toolbar({ * It is rendered in a row of its own above the toolbar, rather than inside it, * so that it is a separate tab stop which comes before the formatting buttons. * The article opens in a new tab, so the draft is not lost. + * + * The link's accessible name is the same text as its tooltip, so what is shown + * on hover is what a screen reader says and what voice control listens for. + * The rest of what a screen reader user needs to know is the link's + * description. Giving it one also stops browsers from using `title` as the + * description, which would read the tooltip out a second time. */ function EditorInfoLink() { + const descriptionId = useId(); + return ( // `flex` keeps the link from stretching to the full width of the row.
@@ -571,8 +579,9 @@ function EditorInfoLink() { href="https://web.hypothes.is/help/using-the-annotation-editor/" target="_blank" rel="noopener noreferrer" - title="About the Annotation editor" - aria-label="About the Annotation editor. Learn what this text field is for. Opens Help Center article in a new tab." + title="Annotation Editor Help" + aria-label="Annotation Editor Help" + aria-describedby={descriptionId} underline="none" variant="custom" > @@ -580,6 +589,12 @@ function EditorInfoLink() { behind it, which is the white background of the annotation card. */} + {/* `hidden`, so that it is only read as the description of the link and + not a second time as text after it. */} +
); } @@ -606,8 +621,8 @@ export type MarkdownEditorProps = { showHelpLink?: boolean; /** - * Whether to display the "About the Annotation editor" link above the - * toolbar. Defaults to false. + * Whether to display the "Annotation Editor Help" link above the toolbar. + * Defaults to false. */ showEditorInfoLink?: boolean; diff --git a/src/sidebar/components/test/MarkdownEditor-test.js b/src/sidebar/components/test/MarkdownEditor-test.js index 14b480f7d24..96c4a403686 100644 --- a/src/sidebar/components/test/MarkdownEditor-test.js +++ b/src/sidebar/components/test/MarkdownEditor-test.js @@ -520,15 +520,14 @@ describe('MarkdownEditor', () => { assert.equal(link.getAttribute('rel'), 'noopener noreferrer'); }); - it('has a tooltip and an accessible name', () => { + it('has a tooltip and the same text as its accessible name', () => { const wrapper = createComponent({ showEditorInfoLink: true }); const link = wrapper.find(linkSelector).getDOMNode(); - assert.equal(link.getAttribute('title'), 'About the Annotation editor'); - assert.equal( - link.getAttribute('aria-label'), - 'About the Annotation editor. Learn what this text field is for. Opens Help Center article in a new tab.', - ); + assert.equal(link.getAttribute('title'), 'Annotation Editor Help'); + // What is shown on hover is what a screen reader says and what voice + // control listens for. + assert.equal(link.getAttribute('aria-label'), link.getAttribute('title')); // The icon is the only content, and it is hidden from assistive // technology, so the name comes from `aria-label` alone. assert.equal(link.textContent, ''); @@ -536,6 +535,64 @@ describe('MarkdownEditor', () => { assert.equal(link.children[0].getAttribute('aria-hidden'), 'true'); }); + it('is described by text that says what it is for and that it opens a new tab', () => { + const wrapper = createComponent( + { showEditorInfoLink: true }, + { connected: true }, + ); + const link = wrapper.find(linkSelector).getDOMNode(); + + // `aria-describedby` takes one or more IDs. There is exactly one here, + // and it is of an element in the same document. + const ids = link.getAttribute('aria-describedby').split(/\s+/); + assert.lengthOf(ids, 1); + const description = document.getElementById(ids[0]); + assert.ok(description); + + assert.equal( + description.textContent.replace(/\s+/g, ' ').trim(), + 'Learn what this text field is for. Opens Help Center article in a new tab.', + ); + // The description does not repeat the name, which is read before it. + assert.notInclude(description.textContent, link.getAttribute('title')); + + // It is only the description of the link: not shown, not read a second + // time as text of its own, and not something the Tab key stops at. + assert.isTrue(description.hidden); + assert.equal(getComputedStyle(description).display, 'none'); + assert.isFalse(link.contains(description)); + assert.notInclude(tabStops(wrapper.getDOMNode()), description); + }); + + it('gives each editor a description of its own', () => { + // Several annotations can be open for editing at once, in one tree. An + // ID used twice would make both links point at the first description. + const editors = [1, 2].map(key => ( + + )); + const wrapper = mount(
{editors}
, { connected: true }); + + const links = [...wrapper.getDOMNode().querySelectorAll(linkSelector)]; + assert.lengthOf(links, 2); + const ids = links.map(link => link.getAttribute('aria-describedby')); + assert.notEqual(ids[0], ids[1]); + + links.forEach((link, index) => { + const described = document.querySelectorAll(`[id="${ids[index]}"]`); + assert.lengthOf(described, 1); + // Each link is described by the element next to it. + assert.equal(described[0], link.nextElementSibling); + }); + }); + it('shows a grey info icon', () => { const wrapper = createComponent( { showEditorInfoLink: true }, From 794b207dffdcd28ab77d8dc7f4abb8cd15d7a50b Mon Sep 17 00:00:00 2001 From: Santiago Regusci Date: Thu, 12 Nov 2026 12:52:39 -0300 Subject: [PATCH 2/2] Editor info link: keep the accessible name as it was The previous commit also changed the link's accessible name to match the new tooltip, and moved the rest of the sentence into a description. That is undone: the accessible name stays the sentence from hypothesis/product-backlog#1753, "About the Annotation editor. Learn what this text field is for. Opens Help Center article in a new tab.", as it was before this branch. Only the tooltip changes, to "Annotation Editor Help". The hidden description element, its `aria-describedby` and the tests for it are removed. Co-Authored-By: Claude Opus 5.5 --- src/sidebar/components/MarkdownEditor.tsx | 17 +---- .../components/test/MarkdownEditor-test.js | 67 ++----------------- 2 files changed, 6 insertions(+), 78 deletions(-) diff --git a/src/sidebar/components/MarkdownEditor.tsx b/src/sidebar/components/MarkdownEditor.tsx index 44428c9f035..9270a641c72 100644 --- a/src/sidebar/components/MarkdownEditor.tsx +++ b/src/sidebar/components/MarkdownEditor.tsx @@ -554,16 +554,8 @@ function Toolbar({ * It is rendered in a row of its own above the toolbar, rather than inside it, * so that it is a separate tab stop which comes before the formatting buttons. * The article opens in a new tab, so the draft is not lost. - * - * The link's accessible name is the same text as its tooltip, so what is shown - * on hover is what a screen reader says and what voice control listens for. - * The rest of what a screen reader user needs to know is the link's - * description. Giving it one also stops browsers from using `title` as the - * description, which would read the tooltip out a second time. */ function EditorInfoLink() { - const descriptionId = useId(); - return ( // `flex` keeps the link from stretching to the full width of the row.
@@ -580,8 +572,7 @@ function EditorInfoLink() { target="_blank" rel="noopener noreferrer" title="Annotation Editor Help" - aria-label="Annotation Editor Help" - aria-describedby={descriptionId} + aria-label="About the Annotation editor. Learn what this text field is for. Opens Help Center article in a new tab." underline="none" variant="custom" > @@ -589,12 +580,6 @@ function EditorInfoLink() { behind it, which is the white background of the annotation card. */} - {/* `hidden`, so that it is only read as the description of the link and - not a second time as text after it. */} -
); } diff --git a/src/sidebar/components/test/MarkdownEditor-test.js b/src/sidebar/components/test/MarkdownEditor-test.js index 96c4a403686..3b2592c7b22 100644 --- a/src/sidebar/components/test/MarkdownEditor-test.js +++ b/src/sidebar/components/test/MarkdownEditor-test.js @@ -520,14 +520,15 @@ describe('MarkdownEditor', () => { assert.equal(link.getAttribute('rel'), 'noopener noreferrer'); }); - it('has a tooltip and the same text as its accessible name', () => { + it('has a tooltip and an accessible name', () => { const wrapper = createComponent({ showEditorInfoLink: true }); const link = wrapper.find(linkSelector).getDOMNode(); assert.equal(link.getAttribute('title'), 'Annotation Editor Help'); - // What is shown on hover is what a screen reader says and what voice - // control listens for. - assert.equal(link.getAttribute('aria-label'), link.getAttribute('title')); + assert.equal( + link.getAttribute('aria-label'), + 'About the Annotation editor. Learn what this text field is for. Opens Help Center article in a new tab.', + ); // The icon is the only content, and it is hidden from assistive // technology, so the name comes from `aria-label` alone. assert.equal(link.textContent, ''); @@ -535,64 +536,6 @@ describe('MarkdownEditor', () => { assert.equal(link.children[0].getAttribute('aria-hidden'), 'true'); }); - it('is described by text that says what it is for and that it opens a new tab', () => { - const wrapper = createComponent( - { showEditorInfoLink: true }, - { connected: true }, - ); - const link = wrapper.find(linkSelector).getDOMNode(); - - // `aria-describedby` takes one or more IDs. There is exactly one here, - // and it is of an element in the same document. - const ids = link.getAttribute('aria-describedby').split(/\s+/); - assert.lengthOf(ids, 1); - const description = document.getElementById(ids[0]); - assert.ok(description); - - assert.equal( - description.textContent.replace(/\s+/g, ' ').trim(), - 'Learn what this text field is for. Opens Help Center article in a new tab.', - ); - // The description does not repeat the name, which is read before it. - assert.notInclude(description.textContent, link.getAttribute('title')); - - // It is only the description of the link: not shown, not read a second - // time as text of its own, and not something the Tab key stops at. - assert.isTrue(description.hidden); - assert.equal(getComputedStyle(description).display, 'none'); - assert.isFalse(link.contains(description)); - assert.notInclude(tabStops(wrapper.getDOMNode()), description); - }); - - it('gives each editor a description of its own', () => { - // Several annotations can be open for editing at once, in one tree. An - // ID used twice would make both links point at the first description. - const editors = [1, 2].map(key => ( - - )); - const wrapper = mount(
{editors}
, { connected: true }); - - const links = [...wrapper.getDOMNode().querySelectorAll(linkSelector)]; - assert.lengthOf(links, 2); - const ids = links.map(link => link.getAttribute('aria-describedby')); - assert.notEqual(ids[0], ids[1]); - - links.forEach((link, index) => { - const described = document.querySelectorAll(`[id="${ids[index]}"]`); - assert.lengthOf(described, 1); - // Each link is described by the element next to it. - assert.equal(described[0], link.nextElementSibling); - }); - }); - it('shows a grey info icon', () => { const wrapper = createComponent( { showEditorInfoLink: true },