Skip to content

Commit 9427e27

Browse files
committed
🐛 FIX: accessibility issue
1 parent 9b02065 commit 9427e27

6 files changed

Lines changed: 24 additions & 4 deletions

File tree

client/layout/sidebar/expandable-heading.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
99
interface ExpandableSidebarHeadingProps {
1010
title: TranslateResult;
1111
count?: number;
12+
countLabel?: string;
1213
compactCount?: boolean;
1314
onClick?: ( event?: MouseEvent< HTMLAnchorElement > ) => void;
1415
customIcon?: ReactNode;
@@ -30,6 +31,7 @@ interface ExpandableSidebarHeadingProps {
3031
const ExpandableSidebarHeading = ( {
3132
title,
3233
count,
34+
countLabel,
3335
compactCount,
3436
icon,
3537
customIcon,
@@ -68,7 +70,9 @@ const ExpandableSidebarHeading = ( {
6870
{ renderedTitle }
6971
<span className="sidebar__actions-and-count">
7072
{ moreMenuActions }
71-
{ count && count > 0 ? <Count count={ count } compact={ compactCount } /> : null }
73+
{ count && count > 0 ? (
74+
<Count count={ count } compact={ compactCount } aria-label={ countLabel } />
75+
) : null }
7276
</span>
7377
{ inlineText && <span className="sidebar__inline-text">{ inlineText }</span> }
7478
</span>

client/layout/sidebar/expandable.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface ExpandableSidebarMenuProps {
2626
className?: string;
2727
title: TranslateResult;
2828
count?: number;
29+
countLabel?: string;
2930
compactCount?: boolean;
3031
onClick?: ( event?: MouseEvent< HTMLAnchorElement > ) => void;
3132
icon?: string | null;
@@ -71,6 +72,7 @@ export const ExpandableSidebarMenu = ( menuProps: ExpandableSidebarMenuProps ) =
7172
className,
7273
title,
7374
count,
75+
countLabel,
7476
compactCount,
7577
onClick,
7678
icon,
@@ -142,6 +144,7 @@ export const ExpandableSidebarMenu = ( menuProps: ExpandableSidebarMenuProps ) =
142144
<ExpandableSidebarHeading
143145
title={ title }
144146
count={ count }
147+
countLabel={ countLabel }
145148
compactCount={ compactCount }
146149
onClick={
147150
typeof onClick === 'function'

client/reader/list-manage/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type ReaderList = {
2020
is_public?: boolean;
2121
is_immutable?: boolean;
2222
feeds: {
23-
id: number;
23+
feed_id: number;
2424
unseen_count: number;
2525
}[];
2626
};

client/reader/sidebar/reader-sidebar-lists/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ const ReaderSidebarLists = ( {
3838
( list.feeds?.reduce( ( total, feed ) => total + ( feed.unseen_count ?? 0 ), 0 ) ?? 0 ),
3939
0 // Initial value of the list unseen count accumulator.
4040
) || 0;
41+
const unseenCountLabel = translate( '%(count)d unseen post', '%(count)d unseen posts', {
42+
count: totalUnseenCount,
43+
args: { count: totalUnseenCount },
44+
comment: '%(count)d is the number of unseen posts.',
45+
} );
4146

4247
return (
4348
<li>
4449
<ExpandableSidebarMenu
4550
expanded={ isOpen ?? false }
4651
title={ translate( 'Lists' ) }
4752
count={ isSeenEnabled ? totalUnseenCount : 0 }
53+
countLabel={ unseenCountLabel as string }
4854
compactCount
4955
onClick={ onClick }
5056
disableFlyout

client/reader/sidebar/reader-sidebar-lists/list-item.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ const ReaderSidebarListsListItem = ( {
7171
const displayTitle = isOwnedByCurrentUser ? list.title : `${ list.title } (${ list.owner })`;
7272
const isSeenEnabled = isAutomattician;
7373
const unseenCount = list.feeds?.reduce( ( t, feed ) => t + ( feed.unseen_count ?? 0 ), 0 ) ?? 0;
74+
const unseenCountLabel = translate( '%(count)d unseen post', '%(count)d unseen posts', {
75+
count: unseenCount,
76+
args: { count: unseenCount },
77+
comment: '%(count)d is the number of unseen posts.',
78+
} );
7479

7580
return (
7681
<MenuItem
@@ -94,7 +99,9 @@ const ReaderSidebarListsListItem = ( {
9499
<div className="sidebar__menu-item-title" title={ displayTitle }>
95100
{ displayTitle }
96101
</div>
97-
{ isSeenEnabled && unseenCount > 0 && <Count count={ unseenCount } compact /> }
102+
{ isSeenEnabled && unseenCount > 0 && (
103+
<Count count={ unseenCount } compact aria-label={ unseenCountLabel as string } />
104+
) }
98105
</AutoDirection>
99106
</MenuItemLink>
100107
</MenuItem>

packages/api-core/src/read-lists/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface ReadList {
88
is_public: boolean;
99
is_immutable?: boolean;
1010
feeds: {
11-
id: number;
11+
feed_id: number;
1212
unseen_count: number;
1313
}[];
1414
}

0 commit comments

Comments
 (0)