diff --git a/src/sidebar/components/SelectionTabs.tsx b/src/sidebar/components/SelectionTabs.tsx index 3a757f4dd6e..137c5a29c18 100644 --- a/src/sidebar/components/SelectionTabs.tsx +++ b/src/sidebar/components/SelectionTabs.tsx @@ -125,15 +125,23 @@ function SelectionTabs({ const showNotesUnavailableMessage = selectedTab === 'note' && noteCount === 0; + // Naive simple English pluralization + const pluralize = (count: number, singular: string, plural: string) => { + return count === 1 ? singular : plural; + }; + const tabCountsSummaryPieces = []; if (annotationCount > 0) { - tabCountsSummaryPieces.push(`${annotationCount} annotations`); + const term = pluralize(annotationCount, 'annotation', 'annotations'); + tabCountsSummaryPieces.push(`${annotationCount} ${term}`); } if (noteCount > 0) { - tabCountsSummaryPieces.push(`${noteCount} notes`); + const term = pluralize(noteCount, 'note', 'notes'); + tabCountsSummaryPieces.push(`${noteCount} ${term}`); } if (orphanCount > 0) { - tabCountsSummaryPieces.push(`${orphanCount} orphans`); + const term = pluralize(noteCount, 'orphan', 'orphans'); + tabCountsSummaryPieces.push(`${orphanCount} ${term}`); } const tabCountsSummary = tabCountsSummaryPieces.join(', '); diff --git a/src/sidebar/components/test/SelectionTabs-test.js b/src/sidebar/components/test/SelectionTabs-test.js index a05006d5a7c..eae38bf8182 100644 --- a/src/sidebar/components/test/SelectionTabs-test.js +++ b/src/sidebar/components/test/SelectionTabs-test.js @@ -340,6 +340,14 @@ describe('SelectionTabs', () => { }, message: '2 annotations, 3 notes, 4 orphans', }, + { + tabCounts: { + annotation: 1, + note: 1, + orphan: 1, + }, + message: '1 annotation, 1 note, 1 orphan', + }, ].forEach(({ tabCounts, message }) => { it('reports annotation count to screen readers', () => { const wrapper = createComponent({