Commit 29092088 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Describe new annotations as "New" in aria-label

Prefix the `aria-label` for annotation `article` elements with "New"
when the annotation is unsaved as an extra hint for screen-reader users.

Related to https://github.com/hypothesis/product-backlog/issues/1344
parent 3c3751af
...@@ -100,10 +100,14 @@ function Annotation({ ...@@ -100,10 +100,14 @@ function Annotation({
[annotation, defaultAuthority, displayNamesEnabled] [annotation, defaultAuthority, displayNamesEnabled]
); );
const annotationDescription = isSaved(annotation)
? annotationRole(annotation)
: `New ${annotationRole(annotation).toLowerCase()}`;
return ( return (
<article <article
className="space-y-4" className="space-y-4"
aria-label={`${annotationRole(annotation)} by ${authorName}`} aria-label={`${annotationDescription} by ${authorName}`}
> >
<AnnotationHeader <AnnotationHeader
annotation={annotation} annotation={annotation}
......
...@@ -79,7 +79,7 @@ describe('Annotation', () => { ...@@ -79,7 +79,7 @@ describe('Annotation', () => {
}); });
describe('annotation accessibility (ARIA) attributes', () => { describe('annotation accessibility (ARIA) attributes', () => {
it('should add an `aria-label` composed of annotation type and author name', () => { it('should add a descriptive `aria-label` for an existing annotation', () => {
const wrapper = createComponent(); const wrapper = createComponent();
assert.equal( assert.equal(
...@@ -87,6 +87,15 @@ describe('Annotation', () => { ...@@ -87,6 +87,15 @@ describe('Annotation', () => {
'Annotation by Richard Lionheart' 'Annotation by Richard Lionheart'
); );
}); });
it('should add a descriptive `aria-label` for a new annotation', () => {
const wrapper = createComponent({ annotation: fixtures.newAnnotation() });
assert.equal(
wrapper.find('article').props()['aria-label'],
'New annotation by Richard Lionheart'
);
});
}); });
describe('annotation quote', () => { describe('annotation quote', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment